diff --git a/rules-tests/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector/Fixture/skip_default_empty.php.inc b/rules-tests/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector/Fixture/skip_default_empty.php.inc new file mode 100644 index 00000000000..fdd457e4e51 --- /dev/null +++ b/rules-tests/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector/Fixture/skip_default_empty.php.inc @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/rules/TypeDeclarationDocblocks/NodeDocblockTypeDecorator.php b/rules/TypeDeclarationDocblocks/NodeDocblockTypeDecorator.php index f9ddfc93148..a74c46e0096 100644 --- a/rules/TypeDeclarationDocblocks/NodeDocblockTypeDecorator.php +++ b/rules/TypeDeclarationDocblocks/NodeDocblockTypeDecorator.php @@ -15,6 +15,7 @@ use PHPStan\Type\ArrayType; use PHPStan\Type\IntegerType; use PHPStan\Type\MixedType; +use PHPStan\Type\NeverType; use PHPStan\Type\Type; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\Comments\NodeDocBlock\DocBlockUpdater; @@ -124,6 +125,10 @@ private function isArrayMixed(Type $type): bool return false; } + if ($type->getItemType() instanceof NeverType) { + return true; + } + if (! $type->getItemType() instanceof MixedType) { return false; } diff --git a/rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php b/rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php index 61a077be7cc..aecb4d1d20b 100644 --- a/rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php +++ b/rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php @@ -89,12 +89,13 @@ public function refactor(Node $node): ?Node continue; } - $this->nodeDocblockTypeDecorator->decorateGenericIterableVarType( + if ($this->nodeDocblockTypeDecorator->decorateGenericIterableVarType( $propertyDefaultType, $propertyPhpDocInfo, $property - ); - $hasChanged = true; + )) { + $hasChanged = true; + } } if (! $hasChanged) {