Skip to content
This repository was archived by the owner on Feb 21, 2019. It is now read-only.

Commit 2ef632d

Browse files
committed
AnnotationsParser::expandClassName() resolves self to original class name
1 parent 01a288c commit 2ef632d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Reflection/AnnotationsParser.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,11 @@ public static function expandClassName($name, \ReflectionClass $reflector)
155155
{
156156
if (empty($name)) {
157157
throw new Nette\InvalidArgumentException('Class name must not be empty.');
158-
}
159158

160-
if ($name[0] === '\\') { // already fully qualified
159+
} elseif ($name === 'self') {
160+
return $reflector->getName();
161+
162+
} elseif ($name[0] === '\\') { // already fully qualified
161163
return ltrim($name, '\\');
162164
}
163165

tests/Reflection/AnnotationsParser.expandClassName.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Assert::exception( function() use ($rcTest) {
2626
Assert::same( 'A', AnnotationsParser::expandClassName('A', $rcTest) );
2727
Assert::same( 'A\B', AnnotationsParser::expandClassName('C', $rcTest) );
2828

29+
Assert::same( 'Test\Space\Foo', AnnotationsParser::expandClassName('self', $rcFoo) );
30+
2931

3032
/*
3133
alias to expand => array(

0 commit comments

Comments
 (0)