From aa09ba2e3c5dae67dbfa9aba72e9e208ac59798b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Votruba?= Date: Thu, 26 Oct 2017 00:08:46 +0200 Subject: [PATCH 1/6] DocBlock: add removeTag() method --- src/DocBlock.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/DocBlock.php b/src/DocBlock.php index 39911406..de320313 100644 --- a/src/DocBlock.php +++ b/src/DocBlock.php @@ -217,4 +217,21 @@ private function addTag(Tag $tag) { $this->tags[] = $tag; } + + /** + * Remove a tag from this DocBlock. + * + * @param Tag $tag The tag to remove. + * + * @return void + */ + public function removeTag(Tag $tagToRemove) + { + foreach ($this->tags as $key => $tag) { + if ($tag === $tagToRemove) { + unset($this->tags[$key]); + break; + } + } + } } From dc5c3da1e35dfef2e5dd2291200045be51098bc0 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 10 Nov 2017 23:20:23 +0100 Subject: [PATCH 2/6] add test for removeTag() --- tests/unit/DocBlockTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/DocBlockTest.php b/tests/unit/DocBlockTest.php index 4a8d4ded..bb9356fa 100644 --- a/tests/unit/DocBlockTest.php +++ b/tests/unit/DocBlockTest.php @@ -13,6 +13,8 @@ namespace phpDocumentor\Reflection; use Mockery as m; +use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; +use phpDocumentor\Reflection\DocBlock\Tags\See; use phpDocumentor\Reflection\Types\Context; /** @@ -249,4 +251,24 @@ public function testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate() $this->assertTrue($fixture->isTemplateEnd()); } + + + /** + * @covers ::__construct + * @covers ::removeTag + * + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated + */ + public function testRemoveTag() + { + $someTag = new Deprecated(); + + $fixture = new DocBlock('', null, [$someTag]); + + $this->assertCount(1, $fixture->getTags()); + + $fixture->removeTag($someTag); + + $this->assertCount(0, $fixture->getTags()); + } } From cbe51788f21eb1995cb3bfbe460cfc4777a88c17 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 10 Nov 2017 23:20:54 +0100 Subject: [PATCH 3/6] add test for removeTag() --- tests/unit/DocBlockTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/DocBlockTest.php b/tests/unit/DocBlockTest.php index bb9356fa..cb6ff1f7 100644 --- a/tests/unit/DocBlockTest.php +++ b/tests/unit/DocBlockTest.php @@ -262,11 +262,16 @@ public function testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate() public function testRemoveTag() { $someTag = new Deprecated(); + $anotherTag = new Deprecated(); $fixture = new DocBlock('', null, [$someTag]); $this->assertCount(1, $fixture->getTags()); + $fixture->removeTag($anotherTag); + + $this->assertCount(1, $fixture->getTags()); + $fixture->removeTag($someTag); $this->assertCount(0, $fixture->getTags()); From 8e885b772bd350960c83314f9265bc385828a807 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 10 Nov 2017 23:21:22 +0100 Subject: [PATCH 4/6] DocBlock: move public method up --- src/DocBlock.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/DocBlock.php b/src/DocBlock.php index de320313..8ed31203 100644 --- a/src/DocBlock.php +++ b/src/DocBlock.php @@ -206,18 +206,6 @@ public function hasTag($name) return false; } - /** - * Adds a tag to this DocBlock. - * - * @param Tag $tag The tag to add. - * - * @return void - */ - private function addTag(Tag $tag) - { - $this->tags[] = $tag; - } - /** * Remove a tag from this DocBlock. * @@ -234,4 +222,16 @@ public function removeTag(Tag $tagToRemove) } } } + + /** + * Adds a tag to this DocBlock. + * + * @param Tag $tag The tag to add. + * + * @return void + */ + private function addTag(Tag $tag) + { + $this->tags[] = $tag; + } } From 75fbd001ec72228315dea105c49c13805771600e Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 10 Nov 2017 23:21:44 +0100 Subject: [PATCH 5/6] travis: drop unused commands --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25fe424a..824706d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: php + dist: trusty + php: - 7.0 - 7.1 @@ -14,14 +16,12 @@ cache: directories: - $HOME/.composer/cache -script: - - vendor/bin/phpunit --coverage-clover=coverage.clover -v - - composer update --no-interaction --prefer-source - - vendor/bin/phpunit -v - before_script: - composer install --no-interaction +script: + - vendor/bin/phpunit --coverage-clover=coverage.clover -v + after_script: - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.clover From fd96574cd80edf06cf97929c8f73aa8ce28ef552 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Fri, 10 Nov 2017 23:22:31 +0100 Subject: [PATCH 6/6] fix cs --- tests/unit/DocBlockTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/DocBlockTest.php b/tests/unit/DocBlockTest.php index cb6ff1f7..277835f3 100644 --- a/tests/unit/DocBlockTest.php +++ b/tests/unit/DocBlockTest.php @@ -14,7 +14,6 @@ use Mockery as m; use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; -use phpDocumentor\Reflection\DocBlock\Tags\See; use phpDocumentor\Reflection\Types\Context; /** @@ -252,7 +251,6 @@ public function testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate() $this->assertTrue($fixture->isTemplateEnd()); } - /** * @covers ::__construct * @covers ::removeTag