8000 Fix the retrieval of the default value for variadic arguments · symfony/symfony@73c5eff · GitHub
[go: up one dir, main page]

Skip to content

Commit 73c5eff

Browse files
committed
Fix the retrieval of the default value for variadic arguments
1 parent 9b7d4c7 commit 73c5eff

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/Symfony/Component/Routing/Loader/AnnotationClassLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ protected function addRoute(RouteCollection $collection, $annot, $globals, \Refl
180180

181181
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
182182
foreach ($method->getParameters() as $param) {
183-
if (!isset($defaults[$param->getName()]) && $param->isOptional()) {
183+
if (!isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
184184
$defaults[$param->getName()] = $param->getDefaultValue();
185185
}
186186
}

src/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/VariadicClass.php renamed to src/Symfony/Component/Routing/Tests/Fixtures/OtherAnnotatedClasses/VariadicClass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
12+
namespace Symfony\Component\Routing\Tests\Fixtures\OtherAnnotatedClasses;
1313

1414
class VariadicClass
1515
{

src/Symfony/Component/Routing/Tests/Loader/AnnotationClassLoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
1717
{
1818
protected $loader;
19+
private $reader;
1920

2021
protected function setUp()
2122
{

src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public function testLoad()
4040
*/
4141
public function testLoadVariadic()
4242
{
43-
$route = new Route(["path" => "/path/to/{id}"]);
43+
$route = new Route(array('path' => '/path/to/{id}'));
4444
$this->reader->expects($this->once())->method('getClassAnnotation');
4545
$this->reader->expects($this->once())->method('getMethodAnnotations')
46-
->will($this->returnValue([$route]));
46+
->will($this->returnValue(array($route)));
4747

48-
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/VariadicClass.php');
48+
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
4949
}
5050

5151
public function testSupports()

0 commit comments

Comments
 (0)
0