diff --git a/composer.json b/composer.json index e508b7121..da4ba5434 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "humbug/php-scoper": "^0.18.6", "justinrainbow/json-schema": "^5.2.12", "nikic/iter": "^2.2", - "phpdocumentor/reflection-docblock": "^5.3", + "phpdocumentor/reflection-docblock": "^5.4", "phpdocumentor/type-resolver": "^1.7", "psr/log": "^3.0", "sebastian/diff": "^5.0", diff --git a/composer.lock b/composer.lock index bdd43c8dd..4db5c602e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ef3c7bc84d266e28f33e96b7e314701d", + "content-hash": "0d7aa61ebf8b2c3c086e8acf33ea654f", "packages": [ { "name": "amphp/amp", @@ -1922,28 +1922,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", + "version": "5.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.1", "ext-filter": "*", - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7", "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" + "mockery/mockery": "~1.3.5", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^5.13" }, "type": "library", "extra": { @@ -1967,15 +1974,15 @@ }, { "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "email": "opensource@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0" }, - "time": "2021-10-19T17:43:47+00:00" + "time": "2024-04-09T21:13:58+00:00" }, { "name": "phpdocumentor/type-resolver", diff --git a/src/Annotation/CompactedFormatter.php b/src/Annotation/CompactedFormatter.php index 3aeef0cb4..c991b608e 100644 --- a/src/Annotation/CompactedFormatter.php +++ b/src/Annotation/CompactedFormatter.php @@ -17,18 +17,38 @@ use phpDocumentor\Reflection\DocBlock\Tag; use phpDocumentor\Reflection\DocBlock\Tags\Formatter; use phpDocumentor\Reflection\DocBlock\Tags\Generic; +use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag; use function array_map; use function explode; use function implode; +use function sprintf; final class CompactedFormatter implements Formatter { public function format(Tag $tag): string { - if (!$tag instanceof Generic) { - return trim('@'.$tag->getName()); + if ($tag instanceof InvalidTag) { + return self::formatInvalidTag($tag); + } + + if ($tag instanceof Generic) { + return self::formatGenericTag($tag); } + return trim('@'.$tag->getName()); + } + + private static function formatInvalidTag(InvalidTag $tag): string + { + return sprintf( + '@%s %s', + $tag->getName(), + $tag, + ); + } + + private static function formatGenericTag(Generic $tag): string + { $description = (string) $tag; if (!str_starts_with($description, '(')) { diff --git a/tests/Compactor/PhpTest.php b/tests/Compactor/PhpTest.php index f6bd1e0ec..f483d722d 100644 --- a/tests/Compactor/PhpTest.php +++ b/tests/Compactor/PhpTest.php @@ -423,8 +423,8 @@ function foo($x) {