added offset-value regression test#1596
Conversation
| ]; | ||
|
|
||
| $data = array_combine($keys, $line); | ||
| $data['languages'] = explode(',', $data['languages']); |
There was a problem hiding this comment.
the reported error on this line is interessting:
1) PHPStan\Rules\Arrays\NonexistentOffsetInArrayDimFetchRuleTest::testBug7469
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'
+'28: Cannot access offset 'languages' on array<'address'|'bankAccount'|'birthDate'|'email'|'firstName'|'ic'|'invoicing'|'invoicingAddress'|'languages'|'lastName'|'note'|'phone'|'radio'|'videoOnline'|'videoTvc'|'voiceExample', mixed>|false.
+28: Cannot access offset 'languages' on array<'address'|'bankAccount'|'birthDate'|'email'|'firstName'|'ic'|'invoicing'|'invoicingAddress'|'languages'|'lastName'|'note'|'phone'|'radio'|'videoOnline'|'videoTvc'|'voiceExample', mixed>|false.
'
https://github.com/phpstan/phpstan-src/runs/7703414883?check_suite_focus=true
There was a problem hiding this comment.
fixed with 4b54905
the error appeared only in the test-suit, not on the reported snippet, because of the phpstan level.
added a IF-case to compensate the possible false return, which happens on php7 only
There was a problem hiding this comment.
made the test compatible with php7 and php8.
there is still a double reported error on line 29 (php7 only), which I guess is a leftover bug?
There was a problem hiding this comment.
Why would it be a bug? The offset is accessed two times on the same line.
ondrejmirtes
left a comment
There was a problem hiding this comment.
Would be nice to sprinkle some assertType calls about the fixed type inference throughout the test files, and reference them from NodeScopeResolverTest too. Thanks!
|
Thank you. Please add NodeScopeResolverTest separately. |
closes phpstan/phpstan#7469
closes phpstan/phpstan#3391
closes phpstan/phpstan#7417