From 9b7d4c7613b5b7e351e32c6f60c08377388150d4 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Sat, 14 Feb 2015 14:38:59 +0100 Subject: [PATCH] Annotated routes with a variadic parameter There are no variadic default values and that generate a fatal error. --- .../AnnotatedClasses/VariadicClass.php | 19 +++++++++++++++++++ .../Tests/Loader/AnnotationFileLoaderTest.php | 14 ++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/VariadicClass.php diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/VariadicClass.php b/src/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/VariadicClass.php new file mode 100644 index 000000000000..f0fe7f095e21 --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/VariadicClass.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses; + +class VariadicClass +{ + public function routeAction(...$params) + { + } +} diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index f0a8a0e32953..94b6d0298153 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -13,6 +13,7 @@ use Symfony\Component\Routing\Loader\AnnotationFileLoader; use Symfony\Component\Config\FileLocator; +use Symfony\Component\Routing\Annotation\Route; class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest { @@ -34,6 +35,19 @@ public function testLoad() $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php'); } + /** + * @requires PHP 5.6 + */ + public function testLoadVariadic() + { + $route = new Route(["path" => "/path/to/{id}"]); + $this->reader->expects($this->once())->method('getClassAnnotation'); + $this->reader->expects($this->once())->method('getMethodAnnotations') + ->will($this->returnValue([$route])); + + $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/VariadicClass.php'); + } + public function testSupports() { $fixture = __DIR__.'/../Fixtures/annotated.php';