diff --git a/rules-tests/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector/Fixture/skip_empty_nested_array.php.inc b/rules-tests/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector/Fixture/skip_empty_nested_array.php.inc deleted file mode 100644 index 6b537f9aed7..00000000000 --- a/rules-tests/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector/Fixture/skip_empty_nested_array.php.inc +++ /dev/null @@ -1,13 +0,0 @@ - [], 'update' => []]; - - public function add(string $key, array $item): void - { - $this->payload['create'][$key] = $item; - } -} diff --git a/rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php b/rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php index d03661f790f..350ce585ad1 100644 --- a/rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php +++ b/rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php @@ -6,7 +6,6 @@ use PhpParser\Comment\Doc; use PhpParser\Node; -use PhpParser\Node\ArrayItem; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Identifier; use PhpParser\Node\PropertyItem; @@ -95,11 +94,6 @@ public function refactor(Node $node): ?Node continue; } - // an empty nested array default generalizes to never[], which then rejects every real value assigned later - if ($this->hasEmptyNestedArray($soleProperty->default)) { - continue; - } - $propertyDefaultType = $this->getType($soleProperty->default); $propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property); @@ -129,29 +123,6 @@ public function refactor(Node $node): ?Node return $node; } - private function hasEmptyNestedArray(Array_ $array): bool - { - foreach ($array->items as $arrayItem) { - if (! $arrayItem instanceof ArrayItem) { - continue; - } - - if (! $arrayItem->value instanceof Array_) { - continue; - } - - if ($arrayItem->value->items === []) { - return true; - } - - if ($this->hasEmptyNestedArray($arrayItem->value)) { - return true; - } - } - - return false; - } - private function hasUsefulParentPropertyVarTag(Class_ $class, Property $property, Type $propertyDefaultType): bool { $propertyName = $this->getName($property);