File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
tests/PHPStan/Analyser/data Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -296,7 +296,7 @@ public static function castToArrayKeyType(Type $offsetType): Type
296296 return $ offsetType ;
297297 }
298298
299- if ($ offsetType instanceof FloatType || $ offsetType instanceof BooleanType) {
299+ if ($ offsetType instanceof FloatType || $ offsetType instanceof BooleanType || $ offsetType -> isNumericString ()-> yes () ) {
300300 return new IntegerType ();
301301 }
302302
Original file line number Diff line number Diff line change @@ -43,4 +43,16 @@ public function doBaz(
4343 assertType ('string&numeric ' , $ numericString );
4444 }
4545
46+ /**
47+ * @param numeric-string $numericString
48+ */
49+ public function doLorem (
50+ string $ numericString
51+ )
52+ {
53+ $ a = [];
54+ $ a [$ numericString ] = 'foo ' ;
55+ assertType ('array<int, \'foo \'> ' , $ a );
56+ }
57+
4658}
You can’t perform that action at this time.
0 commit comments