From a084b5e158d617cb012d9f26eb1932b9f91f4610 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Sun, 19 Jul 2015 22:20:19 +0100 Subject: [PATCH 1/4] Added @covers annotation for testTraitUseIsNotDetectedAsNamespaceUse --- tests/unit/Types/ContextFactoryTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit/Types/ContextFactoryTest.php b/tests/unit/Types/ContextFactoryTest.php index 213d0f7..de8878f 100644 --- a/tests/unit/Types/ContextFactoryTest.php +++ b/tests/unit/Types/ContextFactoryTest.php @@ -89,6 +89,10 @@ public function testReadsAliasesFromProvidedNamespaceAndContent() $this->assertSame($expected, $context->getNamespaceAliases()); } + /** + * @covers ::createForNamespace + * @uses phpDocumentor\Reflection\Types\Context + */ public function testTraitUseIsNotDetectedAsNamespaceUse() { $fixture = new ContextFactory(); From 1c2a09c8a95674268716dcdf98d269dd7fec6ef8 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Sun, 19 Jul 2015 22:20:31 +0100 Subject: [PATCH 2/4] Removed pointless declaration --- tests/unit/Types/ContextFactoryTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/Types/ContextFactoryTest.php b/tests/unit/Types/ContextFactoryTest.php index de8878f..daa1a80 100644 --- a/tests/unit/Types/ContextFactoryTest.php +++ b/tests/unit/Types/ContextFactoryTest.php @@ -95,8 +95,6 @@ public function testReadsAliasesFromProvidedNamespaceAndContent() */ public function testTraitUseIsNotDetectedAsNamespaceUse() { - $fixture = new ContextFactory(); - $php = " Date: Sun, 19 Jul 2015 22:21:04 +0100 Subject: [PATCH 3/4] Added test to check T_CURLY_OPEN and T_DOLLAR_OPEN_CURLY_BRACES are counted as equal to ensure we end at the correct point --- src/Types/ContextFactory.php | 4 ++- tests/unit/Types/ContextFactoryTest.php | 39 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) 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 daa1a80..4a6aece 100644 --- a/tests/unit/Types/ContextFactoryTest.php +++ b/tests/unit/Types/ContextFactoryTest.php @@ -110,6 +110,45 @@ class FooClass { $this->assertSame([], $context->getNamespaceAliases()); } + + /** + * @covers ::createForNamespace + * @uses phpDocumentor\Reflection\Types\Context + */ + public function testAllOpeningBracesAreCheckedWhenSearchingForEndOfClass() + { + $php = 'createForNamespace('Foo', $php); + + $this->assertSame([], $context->getNamespaceAliases()); + } } } From b802985a340487dc08d0db168ca521e69cd0c5c1 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Sun, 19 Jul 2015 22:28:54 +0100 Subject: [PATCH 4/4] Only upload coverage for PHP 5.6 tests --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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"