From 5e1bad36287330a089da7c20c9129e2d14c06123 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Mon, 27 Nov 2017 00:24:51 +0100 Subject: [PATCH] drop asserts where not needed --- examples/04-adding-your-own-tag.php | 1 - src/DocBlock.php | 7 ------- src/DocBlock/Serializer.php | 8 +------- src/DocBlock/Tags/Author.php | 2 -- src/DocBlock/Tags/Link.php | 2 -- src/DocBlock/Tags/Since.php | 1 - 6 files changed, 1 insertion(+), 20 deletions(-) diff --git a/examples/04-adding-your-own-tag.php b/examples/04-adding-your-own-tag.php index 2215a46..e3c5ee6 100644 --- a/examples/04-adding-your-own-tag.php +++ b/examples/04-adding-your-own-tag.php @@ -86,7 +86,6 @@ final class MyTag extends BaseTag implements StaticMethod */ public static function create(string $body, DescriptionFactory $descriptionFactory = null, Context $context = null): MyTag { - Assert::string($body); Assert::notNull($descriptionFactory); return new static($descriptionFactory->create($body, $context)); diff --git a/src/DocBlock.php b/src/DocBlock.php index b94525d..2263732 100644 --- a/src/DocBlock.php +++ b/src/DocBlock.php @@ -56,9 +56,6 @@ final class DocBlock bool $isTemplateStart = false, bool $isTemplateEnd = false ) { - Assert::string($summary); - Assert::boolean($isTemplateStart); - Assert::boolean($isTemplateEnd); Assert::allIsInstanceOf($tags, Tag::class); $this->summary = $summary; @@ -166,8 +163,6 @@ final class DocBlock */ public function getTagsByName(string $name) { - Assert::string($name); - $result = []; /** @var Tag $tag */ @@ -191,8 +186,6 @@ final class DocBlock */ public function hasTag(string $name): bool { - Assert::string($name); - /** @var Tag $tag */ foreach ($this->getTags() as $tag) { if ($tag->getName() === $name) { diff --git a/src/DocBlock/Serializer.php b/src/DocBlock/Serializer.php index 1ed4a2c..8c15dfe 100644 --- a/src/DocBlock/Serializer.php +++ b/src/DocBlock/Serializer.php @@ -45,14 +45,8 @@ class Serializer * @param int|null $lineLength The max length of a line or NULL to disable line wrapping. * @param DocBlock\Tags\Formatter $tagFormatter A custom tag formatter, defaults to PassthroughFormatter. */ - public function __construct(int $indent = 0, string $indentString = ' ', bool $indentFirstLine = true, int $lineLength = null, DocBlock\Tags\Formatter $tagFormatter = null) + public function __construct(int $indent = 0, string $indentString = ' ', bool $indentFirstLine = true, ?int $lineLength = null, ?DocBlock\Tags\Formatter $tagFormatter = null) { - Assert::integer($indent); - Assert::string($indentString); - Assert::boolean($indentFirstLine); - Assert::nullOrInteger($lineLength); - Assert::nullOrIsInstanceOf($tagFormatter, 'phpDocumentor\Reflection\DocBlock\Tags\Formatter'); - $this->indent = $indent; $this->indentString = $indentString; $this->isFirstLineIndented = $indentFirstLine; diff --git a/src/DocBlock/Tags/Author.php b/src/DocBlock/Tags/Author.php index 212cc49..38cf580 100644 --- a/src/DocBlock/Tags/Author.php +++ b/src/DocBlock/Tags/Author.php @@ -84,8 +84,6 @@ final class Author extends BaseTag implements Factory\StaticMethod */ public static function create(string $body) { - Assert::string($body); - $splitTagContent = preg_match('/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $body, $matches); if (!$splitTagContent) { return null; diff --git a/src/DocBlock/Tags/Link.php b/src/DocBlock/Tags/Link.php index 5b1cb39..69cf5cf 100644 --- a/src/DocBlock/Tags/Link.php +++ b/src/DocBlock/Tags/Link.php @@ -35,8 +35,6 @@ final class Link extends BaseTag implements Factory\StaticMethod */ public function __construct(string $link, Description $description = null) { - Assert::string($link); - $this->link = $link; $this->description = $description; } diff --git a/src/DocBlock/Tags/Since.php b/src/DocBlock/Tags/Since.php index 03cb44e..b403cda 100644 --- a/src/DocBlock/Tags/Since.php +++ b/src/DocBlock/Tags/Since.php @@ -60,7 +60,6 @@ final class Since extends BaseTag implements Factory\StaticMethod DescriptionFactory $descriptionFactory = null, TypeContext $context = null ) { - Assert::nullOrString($body); if (empty($body)) { return new static(); }