8000 bug #30776 [Routing] Fix routes annotation loading with glob pattern … · alexpott/symfony@2b73460 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit 2b73460

Browse files
committed
bug symfony#30776 [Routing] Fix routes annotation loading with glob pattern (snoob)
This PR was merged into the 3.4 branch. Discussion ---------- [Routing] Fix routes annotation loading with glob pattern | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#29747 | License | MIT | Doc PR | n/a Loading routes annotation loading with glob pattern triggers an error if one of the targetted directory contains an abstract class. This fixes it Commits ------- c7c45a1 [Routing] Fix routes annotation loading with glob pattern
2 parents 1c92836 + c7c45a1 commit 2b73460

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/Symfony/Component/Routing/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));
8000 6065
$collection->addCollection($this->loader->load($class, $type));
6166
}

src/Symfony/Component/Routing/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
}

src/Symfony/Component/Routing/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)
0