[ 'fooFoo() : null; } }', ], 'nullableMethodWithTernaryIfNullGuard' => [ 'fooFoo(); } }', ], 'nullableMethodWithTernaryEmptyGuard' => [ 'fooFoo(); } }', ], 'nullableMethodWithTernaryIsNullGuard' => [ 'fooFoo(); } }', ], 'nullableMethodWithIfGuard' => [ 'fooFoo(); } } }', ], 'nullableMethodWithTernaryGuardWithThis' => [ 'a = $a; $b = $this->a ? $this->a->fooFoo() : null; } }', ], 'nullableMethodWithTernaryIfNullGuardWithThis' => [ 'a = $a; $b = $this->a === null ? null : $this->a->fooFoo(); } }', ], 'nullableMethodWithIfGuardWithThis' => [ 'a = $a; if ($this->a) { $this->a->fooFoo(); } } }', ], 'nullableMethodWithExceptionThrown' => [ 'fooFoo(); } }', ], 'nullableMethodWithRedefinitionAndElse' => [ 'two = 3; } $one->fooFoo(); } }', ], 'nullableMethodWithBooleanIfGuard' => [ 'fooFoo(); } } }', ], 'nullableMethodWithNonNullBooleanIfGuard' => [ 'fooFoo(); } } }', ], 'nullableMethodWithNonNullBooleanIfGuardAndBooleanAnd' => [ 'fooFoo(); } } }', ], 'nullableMethodInConditionWithIfGuardBefore' => [ 'a && $one->fooFoo()) { // do something } } }', ], 'nullableMethodWithBooleanIfGuardBefore' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedRedefinition' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedRedefinitionInElse' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedNestedRedefinition' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedSwitchRedefinition' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedSwitchRedefinitionDueToException' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedSwitchThatAlwaysReturns' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedNestedRedefinitionWithReturn' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedNestedRedefinitionWithElseReturn' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedNestedRedefinitionWithElseifReturn' => [ 'fooFoo(); } }', ], 'nullableMethodWithGuardedSwitchBreak' => [ 'fooFoo(); break; } } }', ], 'nullableMethodWithGuardedRedefinitionOnThis' => [ 'one = $one; if ($this->one === null) { $this->one = new One(); } $this->one->fooFoo(); } }', ], 'arrayUnionTypeAssertion' => [ ' [ '$ids' => 'array', ], ], 'arrayUnionTypeAssertionWithIsArray' => [ ' [ '$ids' => 'array', ], ], '2dArrayUnionTypeAssertionWithIsArray' => [ '>|null */ function foo() { $ids = rand(0, 1) ? [["hello"]] : null; if (is_array($ids)) { return $ids; } return null; }', ], 'variableReassignment' => [ 'barBar();', ], 'variableReassignmentInIf' => [ 'barBar(); }', ], 'unionTypeFlow' => [ 'fooFoo(); } else { if ($var instanceof Two) { $var->barBar(); } else if ($var) { $var->baz(); } }', ], 'unionTypeFlowWithThrow' => [ 'fooFoo(); } }', ], 'unionTypeFlowWithElseif' => [ 'fooFoo(); }', ], 'typedAdjustment' => [ ' [ '$var' => 'int|string', ], ], 'typeMixedAdjustment' => [ ' [ '$var' => 'int|string', ], ], 'typeAdjustmentIfNull' => [ ' 5 ? new A : null; if ($var === null) { $var = new B; }', 'assertions' => [ '$var' => 'A|B', ], ], 'whileTrue' => [ 'fooFoo()) { $row[0] = "bad"; } } }', ], 'passingParam' => [ 'barBar(new A);', ], 'nullToNullableParam' => [ 'barBar(null);', ], 'objectToNullableObjectParam' => [ 'barBar(new A);', ], 'paramCoercion' => [ 'barBar(); } } }', ], 'paramElseifCoercion' => [ 'barBar(); } elseif ($a instanceof C) { $a->baz(); } } }', ], 'plusPlus' => [ ' [ '$a' => 'int', ], ], 'typedValueAssertion' => [ ' [ ' [ ' 2) { $arr = [5 => [3 => "hello"]]; } if (isset($arr[$a = 5][$b = 3])) { } echo $a; echo $b;', ], 'isIntOnUnaryPlus' => [ ' [ 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodCallWithThis' => [ 'a = $a; $this->a->fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithIfGuard' => [ 'fooFoo(); } } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithWrongBooleanIfGuard' => [ 'fooFoo(); } } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithWrongIfGuardedBefore' => [ 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithWrongBooleanIfGuardBefore' => [ 'fooFoo(); } }', 'error_mesage' => 'PossiblyNullReference', ], 'methodWithMeaninglessCheck' => [ 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithGuardedNestedIncompleteRedefinition' => [ 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithGuardedSwitchRedefinitionNoDefault' => [ 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithGuardedSwitchRedefinitionEmptyDefault' => [ 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'nullableMethodWithGuardedNestedRedefinitionWithUselessElseReturn' => [ 'fooFoo(); } }', 'error_message' => 'PossiblyNullReference', ], 'variableReassignmentInIfWithOutsideCall' => [ 'barBar(); } $one->barBar();', 'error_message' => 'PossiblyUndefinedMethod', ], 'unnecessaryInstanceof' => [ 'fooFoo(); }', 'error_message' => 'FailedTypeResolution', ], 'unNegatableInstanceof' => [ 'fooFoo(); } else { // do something }', 'error_message' => 'FailedTypeResolution', ], 'wrongParam' => [ 'barBar(5);', 'error_message' => 'InvalidArgument', ], 'intToNullableObjectParam' => [ 'barBar(5);', 'error_message' => 'InvalidArgument', ], 'paramCoercionWithBadArg' => [ 'barBar(); } } }', 'error_message' => 'UndefinedMethod', ], 'nullCheckInsideForeachWithNoLeaveStatement' => [ 'fooBar();', 'error_message' => 'NullReference', ], 'possiblyUndefinedMethod' => [ 'foo(); } }', 'error_message' => 'PossiblyUndefinedMethod', ], ]; } }