,error_levels?:string[]}> */ public function providerValidCodeParse() { return [ 'whileCountUpdate' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' [ ' 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' => [ ' [ ' [ ' [ ' [ ' [ ' [ ' 1, A::BAR => 1, A::BAM => 1, ]; if (isset($map[$this->s])) {} } }', ], 'noRedundantConditionWithMixed' => [ ' [], 'error_levels' => ['MissingParamType', 'MixedAssignment'], ], 'sqlTypes' => [ ' [ '$a===' => 'sql-select-string(select * from foo)', '$b===' => 'string(select * from)', '$c===' => 'sql-select-string(select * from foo where i = :i)', ], ], 'numericToStringComparison' => [ ' [ ' [ ' [ ' [ ' 1, 2 => 2, null => "hello", ]; $b = $a[""];', 'assertions' => [ '$b' => 'string', ], ], ]; } /** * @return iterable */ public function providerInvalidCodeParse() { return [ 'neverEqualsType' => [ ' 'TypeDoesNotContainType', ], 'alwaysIdenticalType' => [ ' 'RedundantCondition', ], 'alwaysNotIdenticalType' => [ ' 'RedundantCondition', ], 'neverNotIdenticalType' => [ ' 'TypeDoesNotContainType', ], 'neverEqualsFloatType' => [ ' 'TypeDoesNotContainType', ], 'alwaysIdenticalFloatType' => [ ' 'RedundantCondition', ], 'alwaysNotIdenticalFloatType' => [ ' 'RedundantCondition', ], 'neverNotIdenticalFloatType' => [ ' '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', ], ]; } }