Skip to content

Commit ff11aac

Browse files
committed
[Routing] Fix routes annotation loading with glob pattern
1 parent 02ccc50 commit ff11aac

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

Loader/AnnotationFileLoader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function load($file, $type = null)
5656

5757
$collection = new RouteCollection();
5858
if ($class = $this->findClass($path)) {
59+
$refl = new \ReflectionClass($class);
60+
if ($refl->isAbstract()) {
61+
return;
62+
}
63+
5964
$collection->addResource(new FileResource($path));
6065
$collection->addCollection($this->loader->load($class, $type));
6166
}

Tests/Fixtures/AnnotatedClasses/AbstractClass.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@
1313

1414
abstract class AbstractClass
1515
{
16+
abstract public function abstractRouteAction();
17+
18+
public function routeAction($arg1, $arg2 = 'defaultValue2', $arg3 = 'defaultValue3')
19+
{
20+
}
1621
}

Tests/Loader/AnnotationFileLoaderTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ public function testLoadAnonymousClass()
7878
$this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/AnonymousClassInTrait.php');
7979
}
8080

81+
public function testLoadAbstractClass()
82+
{
83+
$this->reader->expects($this->never())->method('getClassAnnotation');
84+
$this->reader->expects($this->never())->method('getMethodAnnotations');
85+
86+
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/AbstractClass.php');
87+
}
88+
8189
public function testSupports()
8290
{
8391
$fixture = __DIR__.'/../Fixtures/annotated.php';

0 commit comments

Comments
 (0)