Skip to content

Commit

Permalink
Fix replacing route default parameters. (#13514)
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster authored and taylorotwell committed May 11, 2016
1 parent 057d26a commit e164b5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ protected function matchToKeys(array $matches)
*/
protected function replaceDefaults(array $parameters)
{
foreach ($parameters as $key => &$value) {
$value = isset($value) ? $value : Arr::get($this->defaults, $key);
foreach ($parameters as $key => $value) {
$parameters[$key] = isset($value) ? $value : Arr::get($this->defaults, $key);
}

foreach ($this->defaults as $key => $value) {
Expand Down
3 changes: 3 additions & 0 deletions tests/Routing/RoutingRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ public function testRouteParametersDefaultValue()
$router->get('foo/{bar?}', ['uses' => 'RouteTestControllerWithParameterStub@returnParameter'])->defaults('bar', 'foo');
$this->assertEquals('foo', $router->dispatch(Request::create('foo', 'GET'))->getContent());

$router->get('foo/{bar?}', ['uses' => 'RouteTestControllerWithParameterStub@returnParameter'])->defaults('bar', 'foo');
$this->assertEquals('bar', $router->dispatch(Request::create('foo/bar', 'GET'))->getContent());

$router->get('foo/{bar?}', function ($bar = '') { return $bar; })->defaults('bar', 'foo');
$this->assertEquals('foo', $router->dispatch(Request::create('foo', 'GET'))->getContent());
}
Expand Down

0 comments on commit e164b5e

Please sign in to comment.