Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce55704

Browse files
committed
don't process classes with the directory loader
1 parent 3366008 commit ce55704

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ function (\SplFileInfo $current) {
7676
*/
7777
public function supports($resource, $type = null)
7878
{
79+
if ($type && 'annotation' !== $type) {
80+
return false;
81+
}
82+
83+
// classes are handled by the AnnotationClassLoader
84+
if (preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource)) {
85+
return false;
86+
}
87+
7988
if ('annotation' === $type) {
8089
return true;
8190
}

src/Symfony/Component/Routing/Tests/Loader/AnnotationDirectoryLoaderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public function testItSupportsAnyAnnotation()
7474
$this->assertTrue($this->loader->supports(__DIR__.'/../Fixtures/even-with-not-existing-folder', 'annotation'));
7575
}
7676

77+
public function testItDoesNotSupportAnnotatedControllerClasses()
78+
{
79+
$this->assertFalse($this->loader->supports('App\Controller\TestController', 'annotation'));
80+
}
81+
7782
public function testLoadFileIfLocatedResourceIsFile()
7883
{
7984
$this->reader->expects($this->exactly(1))->method('getClassAnnotation');

0 commit comments

Comments
 (0)