diff --git a/PhpCollective/Traits/CommentingTrait.php b/PhpCollective/Traits/CommentingTrait.php index 57ff3bb..fa2270f 100644 --- a/PhpCollective/Traits/CommentingTrait.php +++ b/PhpCollective/Traits/CommentingTrait.php @@ -183,7 +183,7 @@ protected function hasInheritDoc(File $phpcsFile, $docBlockStartIndex, $docBlock protected function containsTypeArray(array $docBlockTypes, string $iterableType = 'array'): bool { foreach ($docBlockTypes as $docBlockType) { - if (str_contains($docBlockType, '[]') || str_starts_with($docBlockType, $iterableType . '<')) { + if (str_contains($docBlockType, '[]') || str_starts_with($docBlockType, $iterableType . '<') || str_starts_with($docBlockType, $iterableType . '{')) { return true; } } diff --git a/tests/PhpCollective/Sniffs/Commenting/DocBlockParamAllowDefaultValueSniffTest.php b/tests/PhpCollective/Sniffs/Commenting/DocBlockParamAllowDefaultValueSniffTest.php index 77a7828..af70bea 100644 --- a/tests/PhpCollective/Sniffs/Commenting/DocBlockParamAllowDefaultValueSniffTest.php +++ b/tests/PhpCollective/Sniffs/Commenting/DocBlockParamAllowDefaultValueSniffTest.php @@ -17,7 +17,7 @@ class DocBlockParamAllowDefaultValueSniffTest extends TestCase */ public function testDocBlockConstSniffer(): void { - $this->assertSnifferFindsErrors(new DocBlockParamAllowDefaultValueSniff(), 4); + $this->assertSnifferFindsErrors(new DocBlockParamAllowDefaultValueSniff(), 5); } /** diff --git a/tests/_data/DocBlockParamAllowDefaultValue/after.php b/tests/_data/DocBlockParamAllowDefaultValue/after.php index a1424fe..a34b335 100644 --- a/tests/_data/DocBlockParamAllowDefaultValue/after.php +++ b/tests/_data/DocBlockParamAllowDefaultValue/after.php @@ -77,4 +77,12 @@ public function toPHP(mixed $value): mixed { public function multipleUnion(int|string|null $value): void { } + + /** + * @param array{msgid: string, msgid_plural: (string | null)}|null $array + * @return void + */ + public function arrayShape(array $array = null): void + { + } } diff --git a/tests/_data/DocBlockParamAllowDefaultValue/before.php b/tests/_data/DocBlockParamAllowDefaultValue/before.php index fe80e3c..2abb19a 100644 --- a/tests/_data/DocBlockParamAllowDefaultValue/before.php +++ b/tests/_data/DocBlockParamAllowDefaultValue/before.php @@ -77,4 +77,12 @@ public function toPHP(mixed $value): mixed { public function multipleUnion(int|string|null $value): void { } + + /** + * @param array{msgid: string, msgid_plural: string|null} $array + * @return void + */ + public function arrayShape(array $array = null): void + { + } }