Skip to content

Commit c55c4ae

Browse files
authored
[TypeDeclarationDocblocks] Widen empty nested array default to mixed[] in DocblockVarArrayFromPropertyDefaultsRector (#8474)
1 parent 1d80900 commit c55c4ae

2 files changed

Lines changed: 0 additions & 42 deletions

File tree

‎rules-tests/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector/Fixture/skip_empty_nested_array.php.inc‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎rules/TypeDeclarationDocblocks/Rector/Class_/DocblockVarArrayFromPropertyDefaultsRector.php‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use PhpParser\Comment\Doc;
88
use PhpParser\Node;
9-
use PhpParser\Node\ArrayItem;
109
use PhpParser\Node\Expr\Array_;
1110
use PhpParser\Node\Identifier;
1211
use PhpParser\Node\PropertyItem;
@@ -95,11 +94,6 @@ public function refactor(Node $node): ?Node
9594
continue;
9695
}
9796

98-
// an empty nested array default generalizes to never[], which then rejects every real value assigned later
99-
if ($this->hasEmptyNestedArray($soleProperty->default)) {
100-
continue;
101-
}
102-
10397
$propertyDefaultType = $this->getType($soleProperty->default);
10498

10599
$propertyPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
@@ -129,29 +123,6 @@ public function refactor(Node $node): ?Node
129123
return $node;
130124
}
131125

132-
private function hasEmptyNestedArray(Array_ $array): bool
133-
{
134-
foreach ($array->items as $arrayItem) {
135-
if (! $arrayItem instanceof ArrayItem) {
136-
continue;
137-
}
138-
139-
if (! $arrayItem->value instanceof Array_) {
140-
continue;
141-
}
142-
143-
if ($arrayItem->value->items === []) {
144-
return true;
145-
}
146-
147-
if ($this->hasEmptyNestedArray($arrayItem->value)) {
148-
return true;
149-
}
150-
}
151-
152-
return false;
153-
}
154-
155126
private function hasUsefulParentPropertyVarTag(Class_ $class, Property $property, Type $propertyDefaultType): bool
156127
{
157128
$propertyName = $this->getName($property);

0 commit comments

Comments
 (0)