diff --git a/.travis.yml b/.travis.yml index 56db0f8..07316c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,7 @@ before_script: - composer install --no-interaction after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover + - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi notifications: irc: "irc.freenode.org#phpdocumentor" diff --git a/src/Types/ContextFactory.php b/src/Types/ContextFactory.php index 3d279c4..fc3f384 100644 --- a/src/Types/ContextFactory.php +++ b/src/Types/ContextFactory.php @@ -77,7 +77,9 @@ public function createForNamespace($namespace, $fileContents) $braceLevel = 0; $firstBraceFound = false; while ($tokens->valid() && ($braceLevel > 0 || !$firstBraceFound)) { - if ($tokens->current() === '{') { + if ($tokens->current() === '{' + || $tokens->current()[0] === T_CURLY_OPEN + || $tokens->current()[0] === T_DOLLAR_OPEN_CURLY_BRACES) { if (!$firstBraceFound) { $firstBraceFound = true; } diff --git a/tests/unit/Types/ContextFactoryTest.php b/tests/unit/Types/ContextFactoryTest.php index 213d0f7..4a6aece 100644 --- a/tests/unit/Types/ContextFactoryTest.php +++ b/tests/unit/Types/ContextFactoryTest.php @@ -89,10 +89,12 @@ public function testReadsAliasesFromProvidedNamespaceAndContent() $this->assertSame($expected, $context->getNamespaceAliases()); } + /** + * @covers ::createForNamespace + * @uses phpDocumentor\Reflection\Types\Context + */ public function testTraitUseIsNotDetectedAsNamespaceUse() { - $fixture = new ContextFactory(); - $php = "assertSame([], $context->getNamespaceAliases()); } + + /** + * @covers ::createForNamespace + * @uses phpDocumentor\Reflection\Types\Context + */ + public function testAllOpeningBracesAreCheckedWhenSearchingForEndOfClass() + { + $php = 'createForNamespace('Foo', $php); + + $this->assertSame([], $context->getNamespaceAliases()); + } } }