,ignored_issues?:list}> */ public function providerValidCodeParse(): iterable { return [ 'orWithAssignment' => [ 'code' => ' 4 ? "test" : null; } function test(): string { $foo = maybeString(); ($foo !== null) || ($foo = ""); return $foo; }' ], 'andWithAssignment' => [ 'code' => ' 4 ? "test" : null; } function test(): string { $foo = maybeString(); ($foo === null) && ($foo = ""); return $foo; }' ], 'assertHardConditionalWithString' => [ 'code' => 'maybeConvert($value)) === null || !$value->isValid()) { throw new Exception(); } return $value; // $value is SomeObject here and cannot be a string }' ], 'assertOnRemainderOfArray' => [ 'code' => ' [ 'code' => ' [ 'code' => 'foo();', 'assertions' => [ '$a' => 'bool', ] ], 'assertVarRedefinedInOpWithOr' => [ 'code' => 'foo();', 'assertions' => [ '$a' => 'bool', ] ], 'assertVarInOrAfterAnd' => [ 'code' => ' [ 'code' => ' [ 'code' => 'foo(); } }' ], 'definedInConditionalAndCheckedInSubbranch' => [ 'code' => 'foo(); } } }' ], 'definedInRhsOfConditionalInNegation' => [ 'code' => 'foo(); } }' ], 'definedInOrRHS' => [ 'code' => 'foo(); }' ], 'possiblyDefinedVarInAssertion' => [ 'code' => 'test()) { return; } echo isset($a); }' ], 'applyTruthyAssertionsToRightHandSideOfAssignment' => [ 'code' => ' [ 'code' => 'c)) { // do something } else { /** @psalm-suppress MixedMethodCall */ $a->foo(); } }' ], 'allowBasicOrAssignment' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 5) { echo "hello"; } elseif ($row = (rand(0, 10) ? [5] : null)) { echo $row[0]; }', ], 'ifNotEqualsFalse' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 5) { } elseif (($a = rand(0, 1) ? new A : null) && $a->foo) {}', ], 'noParadoxAfterConditionalAssignment' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.0' ], 'assignmentForComparison' => [ 'code' => ' 1) {} if ($a) {} }' ], ]; } /** * @return iterable,php_version?:string}> */ public function providerInvalidCodeParse(): iterable { return [ 'assignmentInBranchOfAnd' => [ 'code' => ' 'InvalidReturnStatement', ], 'assignmentInBranchOfOr' => [ 'code' => ' 'InvalidReturnStatement', 'ignored_issues' => [], 'php_version' => '8.0', ], 'assignmentInBranchOfAndReferencedAfterIf' => [ 'code' => ' 'InvalidReturnStatement', ], 'assignmentInBranchOfAndReferencedInElse' => [ 'code' => ' 'InvalidReturnStatement', ], 'assignmentInBranchOfAndReferencedInElseIf' => [ 'code' => ' 'InvalidReturnStatement', ], ]; } }