Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Types/ContextFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ private function extractUseStatement(\ArrayIterator $tokens)
}

if (count($result) == 1) {
$result[] = substr($result[0], strrpos($result[0], '\\') + 1);
$backslashPos = strrpos($result[0], '\\');

if (false !== $backslashPos) {
$result[] = substr($result[0], $backslashPos + 1);
} else {
$result[] = $result[0];
}
}

return array_reverse($result);
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/Types/ContextFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Mockery as m;
use phpDocumentor\Reflection\DocBlock,
phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor;
use \ReflectionClass; // yes, the slash is part of the test

/**
Expand Down Expand Up @@ -49,6 +50,7 @@ public function testReadsAliasesFromClassReflection()
'm' => 'Mockery',
'DocBlock' => 'phpDocumentor\Reflection\DocBlock',
'Tag' => 'phpDocumentor\Reflection\DocBlock\Tag',
'phpDocumentor' => 'phpDocumentor',
'ReflectionClass' => 'ReflectionClass'
];
$context = $fixture->createFromReflector(new ReflectionClass($this));
Expand Down Expand Up @@ -79,6 +81,7 @@ public function testReadsAliasesFromProvidedNamespaceAndContent()
'm' => 'Mockery',
'DocBlock' => 'phpDocumentor\Reflection\DocBlock',
'Tag' => 'phpDocumentor\Reflection\DocBlock\Tag',
'phpDocumentor' => 'phpDocumentor',
'ReflectionClass' => 'ReflectionClass'
];
$context = $fixture->createForNamespace(__NAMESPACE__, file_get_contents(__FILE__));
Expand Down