Skip to content

Commit

Permalink
feat: use isOffsetAccessLegal in NonexistentOffsetInArrayDimFetchRule
Browse files Browse the repository at this point in the history
  • Loading branch information
rajyan committed May 5, 2024
1 parent 5277d55 commit b81633f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Rules/Arrays/NonexistentOffsetInArrayDimFetchRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function processNode(Node $node, Scope $scope): array
return [];
}

if ($scope->isUndefinedExpressionAllowed($node) && !$isOffsetAccessible->no()) {
if ($scope->isUndefinedExpressionAllowed($node) && $isOffsetAccessibleType->isOffsetAccessLegal()->yes()) {
return [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public function testRule(): void
'Cannot access offset \'a\' on Closure(): void.',
253,
],
[
'Cannot access offset \'a\' on array{a: 1, b: 1}|(Closure(): void).',
258,
],
[
'Offset null does not exist on array<int, string>.',
310,
Expand Down Expand Up @@ -252,6 +256,10 @@ public function testRuleBleedingEdge(): void
'Cannot access offset \'a\' on Closure(): void.',
253,
],
[
'Cannot access offset \'a\' on array{a: 1, b: 1}|(Closure(): void).',
258,
],
[
'Offset null does not exist on array<int, string>.',
310,
Expand Down

0 comments on commit b81633f

Please sign in to comment.