,ignored_issues?:list}> */ public function providerValidCodeParse(): iterable { return [ 'nullableMethodWithTernaryGuard' => [ 'code' => 'fooFoo() : null; } }', ], 'nullableMethodWithTernaryIfNullGuard' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithTernaryEmptyGuard' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithTernaryIsNullGuard' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithIfGuard' => [ 'code' => 'fooFoo(); } } }', ], 'nullableMethodWithTernaryGuardWithThis' => [ 'code' => 'a = $a; $b = $this->a ? $this->a->fooFoo() : null; } }', ], 'nullableMethodWithTernaryIfNullGuardWithThis' => [ 'code' => 'a = $a; $b = $this->a === null ? null : $this->a->fooFoo(); } }', ], 'nullableMethodWithIfGuardWithThis' => [ 'code' => 'a = $a; if ($this->a) { $this->a->fooFoo(); } } }', ], 'nullableMethodWithExceptionThrown' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithRedefinitionAndElse' => [ 'code' => 'two = 3; } $one->fooFoo(); } }', ], 'nullableMethodWithBooleanIfGuard' => [ 'code' => 'fooFoo(); } } }', ], 'nullableMethodWithNonNullBooleanIfGuard' => [ 'code' => 'fooFoo(); } } }', ], 'nullableMethodWithNonNullBooleanIfGuardAndBooleanAnd' => [ 'code' => 'fooFoo(); } } }', ], 'nullableMethodInConditionWithIfGuardBefore' => [ 'code' => 'a && $one->fooFoo()) { // do something } } }', ], 'nullableMethodWithBooleanIfGuardBefore' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedRedefinition' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedRedefinitionInElse' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedNestedRedefinition' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedSwitchRedefinition' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedSwitchRedefinitionDueToException' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedSwitchThatAlwaysReturns' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedNestedRedefinitionWithReturn' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedNestedRedefinitionWithElseReturn' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedNestedRedefinitionWithElseifReturn' => [ 'code' => 'fooFoo(); } }', ], 'nullableMethodWithGuardedSwitchBreak' => [ 'code' => 'fooFoo(); break; } } }', ], 'nullableMethodWithGuardedRedefinitionOnThis' => [ 'code' => 'one = $one; if ($this->one === null) { $this->one = new One(); } $this->one->fooFoo(); } }', ], 'arrayUnionTypeAssertion' => [ 'code' => ' [ '$ids' => 'array', ], ], 'arrayUnionTypeAssertionWithIsArray' => [ 'code' => ' [ '$ids' => 'array', ], ], '2dArrayUnionTypeAssertionWithIsArray' => [ 'code' => '>|null */ function foo() { $ids = rand(0, 1) ? [["hello"]] : null; if (is_array($ids)) { return $ids; } return null; }', ], 'variableReassignment' => [ 'code' => 'barBar();', ], 'variableReassignmentInIf' => [ 'code' => 'barBar(); }', ], 'unionTypeFlow' => [ 'code' => 'fooFoo(); } else { if ($var instanceof Two) { $var->barBar(); } else if ($var) { $var->baz(); } }', ], 'unionTypeFlowWithThrow' => [ 'code' => 'fooFoo(); } }', ], 'unionTypeFlowWithElseif' => [ 'code' => 'fooFoo(); }', ], 'typedAdjustment' => [ 'code' => ' [ '$var' => 'int|string', ], ], 'typeMixedAdjustment' => [ 'code' => ' [ '$var' => 'int|string', ], ], 'typeAdjustmentIfNull' => [ 'code' => ' 5 ? new A : null; if ($var === null) { $var = new B; }', 'assertions' => [ '$var' => 'A|B', ], ], 'whileTrue' => [ 'code' => 'fooFoo()) { $row[0] = "bad"; } } }', ], 'passingParam' => [ 'code' => 'barBar(new A);', ], 'nullToNullableParam' => [ 'code' => 'barBar(null);', ], 'objectToNullableObjectParam' => [ 'code' => 'barBar(new A);', ], 'paramCoercion' => [ 'code' => 'barBar(); } } }', ], 'paramElseifCoercion' => [ 'code' => 'barBar(); } elseif ($a instanceof C) { $a->baz(); } } }', ], 'plusPlus' => [ 'code' => ' [ '$a===' => '1', ], ], 'typedValueAssertion' => [ 'code' => ' [ 'code' => ' [ 'code' => 'fooFoo(); $a->barFoo(); } }', 'assertions' => [], ], 'trueFalseTest' => [ 'code' => ' 0) { return true; } return false; } }', ], 'intersectionTypeAfterInstanceof' => [ 'code' => 'foo = "bar"; } } interface I {}', ], 'intersectionTypeInsideInstanceof' => [ 'code' => ' [ 'code' => '&Countable $collection */ $collection = []; count($collection); /** * @param iterable&Countable $collection */ function mycount($collection): int { return count($collection); } mycount($collection);', ], 'scalarTypeParam' => [ 'code' => ' [ 'code' => ' ""]; if (rand(0, 1)) { $optgroup["a"] .= "v"; } if ($optgroup["a"] !== "") {}' ], 'redefineArrayKeyInsideIsStringConditional' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $arr */ function foo(array $arr) : void { foreach ($arr as $k => $_) { if (is_numeric($k)) {} if (!is_numeric($k)) {} } }' ], 'narrowScalar' => [ 'code' => ' [ 'code' => ' $arr */ function foo($arr): void { if (count($arr) === 2) { consume($arr); } } /** * @param array{0:string, 1: string} $input */ function consume($input): void{}' ], 'notDateTimeWithDateTimeInterface' => [ 'code' => 'add($dateInterval); return $dateTime; } else { return $dateTime->add($dateInterval); } } ', ], 'notDateTimeImmutableWithDateTimeInterface' => [ 'code' => 'add($dateInterval); } else { $dateTime->add($dateInterval); return $dateTime; } } ', ], 'CountEqual0MakesNonEmptyArray' => [ 'code' => ',php_version?:string}> */ public function providerInvalidCodeParse(): iterable { return [ 'possiblyUndefinedVariable' => [ 'code' => ' 'PossiblyUndefinedGlobalVariable', ], 'nullableMethodCall' => [ 'code' => 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodCallWithThis' => [ 'code' => 'a = $a; $this->a->fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithIfGuard' => [ 'code' => 'fooFoo(); } } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithWrongBooleanIfGuard' => [ 'code' => 'fooFoo(); } } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithWrongIfGuardedBefore' => [ 'code' => 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithWrongBooleanIfGuardBefore' => [ 'code' => 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithGuardedNestedIncompleteRedefinition' => [ 'code' => 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithGuardedSwitchRedefinitionNoDefault' => [ 'code' => 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithGuardedSwitchRedefinitionEmptyDefault' => [ 'code' => 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithGuardedNestedRedefinitionWithUselessElseReturn' => [ 'code' => 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'variableReassignmentInIfWithOutsideCall' => [ 'code' => 'barBar(); } $one->barBar();', 'error_message' => 'PossiblyUndefinedMethod', ], 'wrongParam' => [ 'code' => 'barBar(5);', 'error_message' => 'InvalidArgument', ], 'intToNullableObjectParam' => [ 'code' => 'barBar(5);', 'error_message' => 'InvalidArgument', ], 'paramCoercionWithBadArg' => [ 'code' => 'barBar(); } } }', 'error_message' => 'UndefinedMethod', ], 'nullCheckInsideForeachWithNoLeaveStatement' => [ 'code' => 'fooBar();', 'error_message' => 'NullReference', ], 'possiblyUndefinedMethod' => [ 'code' => 'foo(); } }', 'error_message' => 'PossiblyUndefinedMethod', ], 'notTrueTest' => [ 'code' => ' 0; } ', 'error_message' => 'InvalidReturnStatement', ], 'notFalseTest' => [ 'code' => ' 0; } ', 'error_message' => 'InvalidReturnStatement', ], 'intersectionTypeClassCheckAfterInstanceof' => [ 'code' => ' 'ArgumentTypeCoercion - src' . DIRECTORY_SEPARATOR . 'somefile.php:14:32 - Argument 1 of takesB expects B,' . ' parent type A&static provided', ], 'intersectionTypeInterfaceCheckAfterInstanceof' => [ 'code' => ' 'InvalidArgument - src' . DIRECTORY_SEPARATOR . 'somefile.php:12:32 - Argument 1 of takesI expects I, A&static provided', ], ]; } }