[ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' 3, "1" => 4, "2" => 5, ]; function takesInt(int $s) : void {} foreach ($foo as $i => $b) { takesInt($i); }', ], 'getValidIntStringOffset' => [ ' 3, "1" => 4, "2" => 5, ]; $a = "2"; echo $foo["2"]; echo $foo[$a];', ], 'checkStringKeyValueAfterKnownIntStringOffset' => [ ' 3, "1" => 4, "2" => 5, ]; $a = "2"; $foo[$a] = 6; function takesInt(int $s) : void {} foreach ($foo as $i => $b) { takesInt($i); }', ], ]; } /** * @return array */ public function providerFileCheckerInvalidCodeParse() { return [ 'neverEqualsType' => [ ' 'TypeDoesNotContainType', ], 'alwaysIdenticalType' => [ ' 'RedundantCondition', ], 'alwaysNotIdenticalType' => [ ' 'RedundantCondition', ], 'neverNotIdenticalType' => [ ' 'RedundantCondition', ], 'phpstanPostedArrayTest' => [ ' 'TypeDoesNotContainType', ], 'ifImpossibleString' => [ ' 'TypeDoesNotContainType', ], 'arrayOffsetImpossibleValue' => [ ' 1, "b" => 2, ]; if ($foo["a"] === 2) {}', 'error_message' => 'TypeDoesNotContainType', ], 'impossibleKeyInForeach' => [ ' 3, "1" => 4, "2" => 5, ]; function takesInt(int $s) : void {} foreach ($foo as $i => $b) { if ($i === 3) {} }', 'error_message' => 'TypeDoesNotContainType', ], 'impossibleValueInForeach' => [ ' 3, "1" => 4, "2" => 5, ]; function takesInt(int $s) : void {} foreach ($foo as $i => $b) { if ($b === $i) {} }', 'error_message' => 'TypeDoesNotContainType', ], 'invalidIntStringOffset' => [ ' 3, "1" => 4, "2" => 5, ]; $a = "3"; echo $foo[$a];', 'error_message' => 'InvalidArrayOffset', ], ]; } }