[ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' 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); }', ], 'regularComparison1' => [ ' [ ' [ ' [ ' [ ' [ ' [], 'error_levels' => ['MixedOperand'], ], 'incrementMixedCall' => [ 'add(function() use (&$i) : void { if (rand(0, 1)) $i++; }); if ($i === 0) {} }', 'assertions' => [], 'error_levels' => ['MissingParamType', 'MixedMethodCall', 'MixedOperand'], ], 'regularValueReconciliation' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ 's = $s; } }', ], 'inArrayAssertionWithSwitch' => [ ' [ ' [ ' [ ' [ ' 0) {} echo $i === 0;', ], 'noRedundantConditionAfterDoWhile' => [ ' 0); echo $i === 0;', ], ]; } /** * @return array */ public function providerFileCheckerInvalidCodeParse() { return [ 'neverEqualsType' => [ ' 'TypeDoesNotContainType', ], 'alwaysIdenticalType' => [ ' 'RedundantCondition', ], 'alwaysNotIdenticalType' => [ ' 'RedundantCondition', ], 'neverNotIdenticalType' => [ ' 'TypeDoesNotContainType', ], 'neverEqualsFloatType' => [ ' 'TypeDoesNotContainType', ], 'alwaysIdenticalFloatType' => [ ' 'RedundantCondition', ], 'alwaysNotIdenticalFloatType' => [ ' 'RedundantCondition', ], 'neverNotIdenticalFloatType' => [ ' 'TypeDoesNotContainType', ], 'SKIPPED-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', ], 'noChangeToVariable' => [ ' 'RedundantCondition', ], 'redefinedIntInIfAndImpossbleComparison' => [ ' 'TypeDoesNotContainType', ], 'badIfOrAssertionWithSwitch' => [ ' 'RedundantCondition', ], ]; } }