Skip to content

Commit 635f751

Browse files
committed
foreach $type->getConstantArrays()
1 parent ef06222 commit 635f751

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/Rules/Variables/CompactVariablesRule.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,19 @@ public function processNode(Node $node, Scope $scope): array
7070
*/
7171
private function findConstantStrings(Type $type): array
7272
{
73-
if (count($type->getConstantStrings()) === 1) {
73+
if (count($type->getConstantStrings()) > 0) {
7474
return $type->getConstantStrings();
7575
}
7676

77-
if (count($type->getConstantArrays()) === 1) {
78-
$result = [];
79-
foreach ($type->getConstantArrays()[0]->getValueTypes() as $valueType) {
77+
$result = [];
78+
foreach ($type->getConstantArrays() as $constantArrayType) {
79+
foreach ($constantArrayType->getValueTypes() as $valueType) {
8080
$constantStrings = $this->findConstantStrings($valueType);
8181
$result = array_merge($result, $constantStrings);
8282
}
83-
84-
return $result;
8583
}
8684

87-
return [];
85+
return $result;
8886
}
8987

9088
}

0 commit comments

Comments
 (0)