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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Rector\Tests\TypeDeclarationDocblocks\Rector\Class_\DocblockVarArrayFromPropertyDefaultsRector\Fixture;

final class SkipDefaultEmpty
{
private array $names = [];
}

?>
5 changes: 5 additions & 0 deletions rules/TypeDeclarationDocblocks/NodeDocblockTypeDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading