Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CakePHP/Sniffs/Commenting/TypeHintSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ protected function getSortedTypeHint(array $types): string
*/
protected function renderUnionTypes(array $typeNodes): string
{
// Remove parenthesis added by phpstan around union and intersection types
return preg_replace(
['/ ([\|&]) /', '/<\(/', '/\)>/'],
['${1}', '<', '>'],
['/ ([\|&]) /', '/<\(/', '/\)>/', '/\), /', '/, \(/'],
['${1}', '<', '>', ', ', ', '],
implode('|', $typeNodes)
);
}
Expand Down
3 changes: 3 additions & 0 deletions CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ function test()

/** @psalm-var null|scalar|class-string<\Cake\I18n\Number>|array $testVar2 */
$testVar2;

/** @var string|null|array<string|int, array<mixed, array<string>|string|null>|string|null>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be missing closing tag though

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's impossible to read, but after breaking it down manually, it should be right.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the closing tag of */
For the comment to be valid docblock

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yea! good catch!

$arrays;
}
3 changes: 3 additions & 0 deletions CakePHP/Tests/Commenting/TypeHintUnitTest.1.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ function test()

/** @psalm-var array|class-string<\Cake\I18n\Number>|scalar|null $testVar2 */
$testVar2;

/** @var array<string|int, array<mixed, array<string>|string|null>|string|null>|string|null
$arrays;
}
1 change: 1 addition & 0 deletions CakePHP/Tests/Commenting/TypeHintUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function getWarningList($testFile = '')
24 => 1,
25 => 1,
37 => 1,
40 => 1,
];

default:
Expand Down