[ ' [ '$a' => 'int', ], ], 'methodTypeHints' => [ ' [ '$a' => 'int', ], ], 'nullCoalesce' => [ ' [ '$a' => 'string|null', ], ], 'nullCoalesceWithNullableOnLeft' => [ ' 5 ? "hello" : null; } $a = foo() ?? "goodbye";', 'assertions' => [ '$a' => 'string', ], ], 'nullCoalesceWithReference' => [ ' [ '$a' => 'mixed', ], ], 'spaceship' => [ ' 1;', 'assertions' => [ '$a' => 'int', ], ], 'defineArray' => [ ' [ '$a' => 'string', ], ], 'anonymousClassLogger' => [ 'logger = $logger; } } $app = new Application; $app->setLogger(new class implements Logger { /** @return void */ public function log(string $msg) { echo $msg; } });', ], 'anonymousClassFunctionReturnType' => [ 'f());', ], 'anonymousClassStatement' => [ ' [ 'i = new class implements I {}; } public function foo2(): void {} // commenting this line out fixes }', ], 'anonymousClassExtendsWithThis' => [ 'foo(); return 42; } };', ], 'returnAnonymousClass' => [ ' [ ' [ ' * @psalm-generator-return string */ function fooFoo(int $i): Generator { if ($i === 1) { return "bash"; } yield 1; }', ], 'generatorDelegation' => [ ' */ function count_to_ten(): Generator { yield 1; yield 2; yield from [3, 4]; yield from new ArrayIterator([5, 6]); yield from seven_eight(); return yield from nine_ten(); } /** * @return Generator */ function seven_eight(): Generator { yield 7; yield from eight(); } /** * @return Generator */ function eight(): Generator { yield 8; } /** * @return Generator */ function nine_ten(): Generator { yield 9; return 10; } $gen = count_to_ten(); foreach ($gen as $num) { echo "$num "; } $gen2 = $gen->getReturn();', 'assertions' => [ '$gen' => 'Generator', '$gen2' => 'int', ], 'error_levels' => ['MixedAssignment'], ], 'generatorWithNestedYield' => [ ' [ ' [ ' [ ' */ function other_generator() : Generator { yield "traffic"; return 1; } /** * @return Generator */ function foo() : Generator { $a = yield from other_generator(); takesInt($a); } foreach (foo() as $s) { takesString($s); }', ], 'expectNonNullableTypeWithYield' => [ ' [ ' 'UndefinedClass', ], 'anonymousClassWithInvalidFunctionReturnType' => [ ' 'InvalidReturnStatement', ], 'expectNonNullableTypeWithNullReturn' => [ ' 'NullableReturnStatement', ], ]; } }