,ignored_issues?:list}> */ public function providerValidCodeParse(): iterable { return [ 'nullTypeRemovedAfterNegatedAssertionAgainstArrayOfInt' => [ 'code' => ' [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { return $x; } throw new \Exception(); } ', ], 'typeNotChangedAfterAssertionAgainstArrayOfMixed' => [ 'code' => ' $y * @return int|null */ function assertInArray($x, $y) { if (!in_array($x, $y, true)) { throw new \Exception(); } return $x; }', ], 'unionTypeReconciledToUnionTypeOfHaystackValueTypes' => [ 'code' => ' $y * @return int|string */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { return $x; } throw new \Exception(); } ', ], 'unionTypesReducedToIntersectionWithinAssertion' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { return $x; } throw new Exception(); }', ], 'unionTypesReducedToIntersectionOutsideOfNegatedAssertion' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (!in_array($x, $y, true)) { throw new Exception(); } return $x; }', ], 'assertInArrayOfNotIntersectingTypeReturnsOriginalTypeOutsideOfAssertion' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { throw new \Exception(); } return $x; }', 'assertions' => [], 'error_level' => ['RedundantConditionGivenDocblockType', 'DocblockTypeContradiction'], ], 'assertNegatedInArrayOfNotIntersectingTypeReturnsOriginalType' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (!in_array($x, $y, true)) { return $x; } throw new \Exception(); }', 'assertions' => [], 'error_level' => ['RedundantConditionGivenDocblockType'], ], 'assertAgainstListOfLiteralsAndScalarUnion' => [ 'code' => ' $y * @return "a"|"b" */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { return $x; } throw new Exception(); }', ], 'assertAgainstListOfLiteralsAndScalarUnionTypeHint' => [ 'code' => ' $y * @return "a"|"b" */ function assertInArray(string|bool $x, $y) { if (in_array($x, $y, true)) { return $x; } throw new Exception(); }', 'assertions' => [], 'ignored_issues' => [], 'php_version' => '8.0' ], 'in_arrayNullOrString' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.0' ], 'in_array-mixed-twice' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.0' ], 'in_array-string-twice' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.0' ], 'in_array-keyed-array-string-twice' => [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.0' ], ]; } /** * @return iterable,php_version?:string}> */ public function providerInvalidCodeParse(): iterable { return [ 'typeNotChangedAfterNegatedAssertionAgainstUnsealedArrayOfMixed' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (!in_array($x, $y, true)) { return $x; } throw new \Exception(); } ', 'error_message' => 'NullableReturnStatement', ], 'typeNotChangedAfterNegatedAssertionAgainstUnsealedArrayOfUnionType' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (!in_array($x, $y, true)) { return $x; } throw new \Exception(); } ', 'error_message' => 'NullableReturnStatement', ], 'initialTypeRemainsOutsideOfAssertion' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { throw new Exception(); } return $x; }', 'error_message' => 'InvalidReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:11:32 - The inferred type \'bool|int\' does not match the declared return type \'int\' for assertInArray', ], 'initialTypeRemainsWithinTheNegatedAssertion' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (!in_array($x, $y, true)) { return $x; } throw new Exception(); }', 'error_message' => 'InvalidReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:9:36 - The inferred type \'bool|int\' does not match the declared return type \'int\' for assertInArray', ], 'assertInArrayOfNotIntersectingTypeTriggersTypeContradiction' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { throw new \Exception(); } return $x; }', 'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always falsy', ], 'assertNegatedInArrayOfNotIntersectingTypeTriggersRedundantCondition' => [ 'code' => ' $y * @return int */ function assertInArray($x, $y) { if (!in_array($x, $y, true)) { return $x; } throw new \Exception(); }', 'error_message' => 'RedundantConditionGivenDocblockType - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type true is always truthy', ], 'assertInArrayOfNotIntersectingTypeTriggersDocblockTypeContradiction' => [ 'code' => ' $y * @return string */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { return $x; } throw new \Exception(); }', 'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always falsy', ], 'assertInArrayOfNotIntersectingTypeReturnsTriggersDocblockTypeContradiction' => [ 'code' => ' $y * @return string */ function assertInArray($x, $y) { if (in_array($x, $y, true)) { return $x; } throw new \Exception(); }', 'error_message' => 'DocblockTypeContradiction - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:29 - Operand of type false is always falsy', 'ignored_issues' => ['RedundantConditionGivenDocblockType'], ], 'inArrayDetectType' => [ 'code' => ' 'RedundantCondition', ], 'inArrayRemoveInvalid' => [ 'code' => ' 'RedundantCondition', ], ]; } }