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 diff --git a/src/DocBlock.php b/src/DocBlock.php index 39911406..8ed31203 100644 --- a/src/DocBlock.php +++ b/src/DocBlock.php @@ -206,6 +206,23 @@ public function hasTag($name) return false; } + /** + * 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; + } + } + } + /** * Adds a tag to this DocBlock. * diff --git a/tests/unit/DocBlockTest.php b/tests/unit/DocBlockTest.php index 4a8d4ded..277835f3 100644 --- a/tests/unit/DocBlockTest.php +++ b/tests/unit/DocBlockTest.php @@ -13,6 +13,7 @@ namespace phpDocumentor\Reflection; use Mockery as m; +use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; use phpDocumentor\Reflection\Types\Context; /** @@ -249,4 +250,28 @@ public function testDocBlockKnowsIfItIsTheEndOfADocBlockTemplate() $this->assertTrue($fixture->isTemplateEnd()); } + + /** + * @covers ::__construct + * @covers ::removeTag + * + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Deprecated + */ + 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()); + } }