Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/8.x' into 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlindaruk committed Oct 4, 2022
2 parents c9c8828 + b77b908 commit 51abec6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
const VERSION = '8.83.24';
const VERSION = '8.83.25';

/**
* The base path for the Laravel installation.
Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ protected function parseControllerCallback()
return Str::parseCallback($this->action['uses']);
}

/**
* Flush the cached container instance on the route.
*
* @return void
*/
public function flushController()
{
$this->controller = null;
}

/**
* Determine if the route matches a given request.
*
Expand Down
31 changes: 31 additions & 0 deletions tests/Routing/RoutingRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,25 @@ public function testResponseIsReturned()
$this->assertNotInstanceOf(JsonResponse::class, $response);
}

public function testRouteFlushController()
{
$container = new Container;
$router = $this->getRouter();

$router->get('count', ActionCountStub::class);
$request = Request::create('count', 'GET');

$response = $router->dispatch($request);
$this->assertSame(1, (int) $response->getContent());

$response = $router->dispatch($request);
$this->assertSame(2, (int) $response->getContent());

$request->route()->flushController();
$response = $router->dispatch($request);
$this->assertSame(1, (int) $response->getContent());
}

public function testJsonResponseIsReturned()
{
$router = $this->getRouter();
Expand Down Expand Up @@ -2304,6 +2323,18 @@ public function __invoke()
}
}

class ActionCountStub
{
protected $count = 0;

public function __invoke()
{
$this->count++;

return $this->count;
}
}

interface ExampleMiddlewareContract
{
//
Expand Down

0 comments on commit 51abec6

Please sign in to comment.