8000 [Routing] Fix the annotation loader taking a class constant as a begi… · symfony/symfony@43c7f9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 43c7f9b

Browse files
committed
[Routing] Fix the annotation loader taking a class constant as a beginning of a class name
1 parent 1d43d9c commit 43c7f9b

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ protected function findClass($file)
9696
$token = $tokens[$i];
9797

9898
if (!isset($token[1])) {
99+
$class = false;
100+
99101
continue;
100102
}
101103

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses;
4+
5+
trait FooTrait
6+
{
7+
public function doBar()
8+
{
9+
$baz = self::class;
10+
if (true) {
11+
}
12+
}
13+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public function testLoad()
3535
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
3636
}
3737

38+
/**
39+
* @requires PHP 5.4
40+
*/
41+
public function testLoadTraitWithClassConstant()
42+
{
43+
$this->reader->expects($this->never())->method('getClassAnnotation');
44+
45+
$this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php');
46+
}
47+
3848
/**
3949
* @requires PHP 5.6
4050
*/

0 commit comments

Comments
 (0)
0