Fix the retrieval of the default value for variadic arguments
This commit is contained in:
parent
9b7d4c7613
commit
73c5eff44d
@ -180,7 +180,7 @@ abstract class AnnotationClassLoader implements LoaderInterface
|
|||||||
|
|
||||||
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
|
$defaults = array_replace($globals['defaults'], $annot->getDefaults());
|
||||||
foreach ($method->getParameters() as $param) {
|
foreach ($method->getParameters() as $param) {
|
||||||
if (!isset($defaults[$param->getName()]) && $param->isOptional()) {
|
if (!isset($defaults[$param->getName()]) && $param->isDefaultValueAvailable()) {
|
||||||
$defaults[$param->getName()] = $param->getDefaultValue();
|
$defaults[$param->getName()] = $param->getDefaultValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
|
namespace Symfony\Component\Routing\Tests\Fixtures\OtherAnnotatedClasses;
|
||||||
|
|
||||||
class VariadicClass
|
class VariadicClass
|
||||||
{
|
{
|
@ -16,6 +16,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
class AnnotationClassLoaderTest extends AbstractAnnotationLoaderTest
|
||||||
{
|
{
|
||||||
protected $loader;
|
protected $loader;
|
||||||
|
private $reader;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
|
@ -40,12 +40,12 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
|
|||||||
*/
|
*/
|
||||||
public function testLoadVariadic()
|
public function testLoadVariadic()
|
||||||
{
|
{
|
||||||
$route = new Route(["path" => "/path/to/{id}"]);
|
$route = new Route(array('path' => '/path/to/{id}'));
|
||||||
$this->reader->expects($this->once())->method('getClassAnnotation');
|
$this->reader->expects($this->once())->method('getClassAnnotation');
|
||||||
$this->reader->expects($this->once())->method('getMethodAnnotations')
|
$this->reader->expects($this->once())->method('getMethodAnnotations')
|
||||||
->will($this->returnValue([$route]));
|
->will($this->returnValue(array($route)));
|
||||||
|
|
||||||
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/VariadicClass.php');
|
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSupports()
|
public function testSupports()
|
||||||
|
Reference in New Issue
Block a user