Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2b73460

Browse filesBrowse files
committed
bug #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 | #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
Copy full SHA for 2b73460

File tree

Expand file treeCollapse file tree

3 files changed

+18
-0
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+18
-0
lines changed

‎src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php
+5Lines 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
}

‎src/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php
+5Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php
+8Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.