Skip to content

Commit

Permalink
build(deps): Upgrade to phpdocumentor/reflection-docblock 5.4 (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Apr 23, 2024
1 parent 6aae0ae commit 68c1ba7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
31 changes: 19 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions src/Annotation/CompactedFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '(')) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Compactor/PhpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ function foo($x) {
<?php
/**
* @param (string|stdClass $x
*/
@param (string|stdClass $x
*/
function foo($x) {
}
PHP,
Expand Down

0 comments on commit 68c1ba7

Please sign in to comment.