Skip to content

Commit 6325d1a

Browse files
Improve
1 parent 6f99f04 commit 6325d1a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Rules/Arrays/InvalidKeyInArrayDimFetchRule.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public function processNode(Node $node, Scope $scope): array
4747
static fn (Type $varType): bool => $varType->isArray()->no(),
4848
)->getType();
4949

50-
if ($varType instanceof ErrorType || $varType->isArray()->no()) {
50+
if ($varType instanceof ErrorType) {
51+
return [];
52+
}
53+
54+
$isArray = $varType->isArray();
55+
if ($isArray->no() || ($isArray->maybe() && !$this->reportMaybes)) {
5156
return [];
5257
}
5358

@@ -68,7 +73,10 @@ public function processNode(Node $node, Scope $scope): array
6873

6974
return [
7075
RuleErrorBuilder::message(
71-
sprintf('%s array key type %s.', $isSuperType->no() ? 'Invalid' : 'Possibly invalid', $dimensionType->describe(VerbosityLevel::typeOnly())),
76+
sprintf(
77+
'%s array key type %s.', $isArray->yes() && $isSuperType->no() ? 'Invalid' : 'Possibly invalid',
78+
$dimensionType->describe(VerbosityLevel::typeOnly()),
79+
),
7280
)->identifier('offsetAccess.invalidOffset')->build(),
7381
];
7482
}

0 commit comments

Comments
 (0)