From d83fa01373223c39a11ac90f89d38aad8dba6289 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Mon, 18 May 2020 12:43:38 +0200 Subject: [PATCH 1/4] Update composer.json. --- composer.json | 2 +- src/Symfony/Component/PropertyInfo/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9ad5e39ad2ca5..459854f172999 100644 --- a/composer.json +++ b/composer.json @@ -100,7 +100,7 @@ "egulias/email-validator": "~1.2,>=1.2.8|~2.0", "symfony/phpunit-bridge": "^3.4.31|^4.3.4|~5.0", "symfony/security-acl": "~2.8|~3.0", - "phpdocumentor/reflection-docblock": "^3.0|^4.0" + "phpdocumentor/reflection-docblock": "^3.0||^4.0||^5.0" }, "conflict": { "monolog/monolog": ">=2", diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index f19e3d1e2a2d7..2e355759ac53b 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -30,7 +30,7 @@ "symfony/serializer": "~2.8|~3.0|~4.0", "symfony/cache": "~3.1|~4.0", "symfony/dependency-injection": "~3.3|~4.0", - "phpdocumentor/reflection-docblock": "^3.0|^4.0", + "phpdocumentor/reflection-docblock": "^3.0||^4.0||^5.0", "doctrine/annotations": "~1.7" }, "conflict": { From 4664618b9004ca3100a52af2e3e279e542d731fb Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Mon, 18 May 2020 15:16:12 +0200 Subject: [PATCH 2/4] Update composer.json for consistency. --- composer.json | 2 +- src/Symfony/Component/PropertyInfo/composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 459854f172999..abae094853a83 100644 --- a/composer.json +++ b/composer.json @@ -100,7 +100,7 @@ "egulias/email-validator": "~1.2,>=1.2.8|~2.0", "symfony/phpunit-bridge": "^3.4.31|^4.3.4|~5.0", "symfony/security-acl": "~2.8|~3.0", - "phpdocumentor/reflection-docblock": "^3.0||^4.0||^5.0" + "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0" }, "conflict": { "monolog/monolog": ">=2", diff --git a/src/Symfony/Component/PropertyInfo/composer.json b/src/Symfony/Component/PropertyInfo/composer.json index 2e355759ac53b..6f3267e02a5e2 100644 --- a/src/Symfony/Component/PropertyInfo/composer.json +++ b/src/Symfony/Component/PropertyInfo/composer.json @@ -30,7 +30,7 @@ "symfony/serializer": "~2.8|~3.0|~4.0", "symfony/cache": "~3.1|~4.0", "symfony/dependency-injection": "~3.3|~4.0", - "phpdocumentor/reflection-docblock": "^3.0||^4.0||^5.0", + "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", "doctrine/annotations": "~1.7" }, "conflict": { From 07cfd92be0f790751baeb1359d8983320d6cca5d Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Mon, 18 May 2020 12:43:56 +0200 Subject: [PATCH 3/4] Add new test. --- .../Tests/Extractor/PhpDocExtractorTest.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php index 4c19a86b43767..c17615e7d87f2 100644 --- a/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php +++ b/src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php @@ -102,7 +102,7 @@ public function typesProvider() ['donotexist', null, null, null], ['staticGetter', null, null, null], ['staticSetter', null, null, null], - ['emptyVar', null, null, null], + ['emptyVar', null, 'This should not be removed.', null], ]; } @@ -191,6 +191,14 @@ public function testReturnNullOnEmptyDocBlock() $this->assertNull($this->extractor->getShortDescription(EmptyDocBlock::class, 'foo')); } + public function testReturnNullOnIncompleteDocBlock() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Failed to get the description of the @var tag "foo" for class "Symfony\Component\PropertyInfo\Tests\Extractor\IncompleteDocBlock". Please check that the @var tag is correctly defined.'); + + $this->extractor->getShortDescription(IncompleteDocBlock::class, 'foo'); + } + public function dockBlockFallbackTypesProvider() { return [ @@ -215,6 +223,16 @@ public function testDocBlockFallback($property, $types) } } +class IncompleteDocBlock +{ + /** + * @var + * @ORM\Id + * @ORM\Column(name="FOO", type="integer") + */ + public $foo; +} + class EmptyDocBlock { public $foo; From b5f1423fb9a30346fd164eee6c5c09c79cd6e59b Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Mon, 18 May 2020 12:44:16 +0200 Subject: [PATCH 4/4] Update PhpDocExtractor. --- .../Component/PropertyInfo/Extractor/PhpDocExtractor.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php index 787bf4b5d2d09..f6842dbe36a75 100644 --- a/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php +++ b/src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php @@ -83,6 +83,10 @@ public function getShortDescription($class, $property, array $context = []) } foreach ($docBlock->getTagsByName('var') as $var) { + if (is_a($var, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { + throw new \InvalidArgumentException(sprintf('Failed to get the description of the @var tag "%s" for class "%s". Please check that the @var tag is correctly defined.', $property, $class)); + } + $varDescription = $var->getDescription()->render(); if (!empty($varDescription)) { @@ -137,6 +141,10 @@ public function getTypes($class, $property, array $context = []) $types = []; /** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */ foreach ($docBlock->getTagsByName($tag) as $tag) { + if (is_a($tag, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { + return null; + } + if ($tag && null !== $tag->getType()) { $types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType())); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy