Report float and null offset based on PHP version#4406
Report float and null offset based on PHP version#4406ondrejmirtes merged 1 commit intophpstan:2.1.xfrom
Conversation
6b9f23d to
cd4e33c
Compare
cd4e33c to
456c943
Compare
|
This pull request has been marked as ready for review. |
| namespace InvalidKeyArrayDimFetch; | ||
|
|
||
| $a = []; | ||
| $foo = $a[null]; |
There was a problem hiding this comment.
I moved PHP-related errors to the end for an easier handling in tests.
| $a[true]; | ||
| $a[false]; | ||
|
|
||
| /** @var string|null $stringOrNull */ |
There was a problem hiding this comment.
I changed for a valid union here and move the invalid string|null to the end
|
BaselineNeonErrorFormatterIntegrationTest::testErrorWithTrait failure seems unrelated and doesn't fail locally. |
| { | ||
|
|
||
| public static function getType(): Type | ||
| public static function getType(?PhpVersion $phpVersion = null): Type |
There was a problem hiding this comment.
It's used in ArrayType and ConstantArrayType
phpstan-src/src/Type/ArrayType.php
Line 273 in 2548dbb
and I don't have a PHPVersion here
|
|
||
| public function __construct( | ||
| private RuleLevelHelper $ruleLevelHelper, | ||
| private PhpVersion $phpVersion, |
There was a problem hiding this comment.
More modern approach is to get PhpVersions from Scope (a separate class).
There was a problem hiding this comment.
Does it means that all the method from PhpVersion should be deprecated/moved into PhpVersions ?
|
Thank you! |
Closes phpstan/phpstan#13592
We will still need an option to report array key cast, especially for boolean keys.
Partially solves phpstan/phpstan#7864