,error_levels?:string[]}> */ public function providerValidCodeParse(): iterable { return [ 'varCallableParamReturnType' => [ ' [ ' [ ' $a . "blah"; }', 'assertions' => [], 'error_levels' => [], '7.4', ], 'callableWithNonInvokable' => [ ' [ ' [ ' [ ' [ 'callable = $callable; } public function callTheCallableDirectly(): bool { return ($this->callable)(); } public function callTheCallableIndirectly(): bool { $r = $this->callable; return $r(); } }', ], 'nullableReturnTypeShorthand' => [ ' [ ' [ ' $b; } } f("strcmp"); f([new C, "m"]); f([C::class, "m"]);', ], 'callableWithSpaces' => [ ' [ ' [ ' $values * @psalm-param pure-callable(int):int $num_func * * @psalm-pure */ function max_by(array $values, callable $num_func) : ?int { $max = null; $max_num = null; foreach ($values as $value) { $value_num = $num_func($value); if (null === $max_num || $value_num >= $max_num) { $max = $value; $max_num = $value_num; } } return $max; } $c = max_by([1, 2, 3], function(int $a): int { return $a + 5; }); echo $c;', ], ]; } /** * @return iterable */ public function providerInvalidCodeParse(): iterable { return [ 'impureCallableArgument' => [ ' $values * @psalm-param pure-callable(int):int $num_func * * @psalm-pure */ function max_by(array $values, callable $num_func) : ?int { $max = null; $max_num = null; foreach ($values as $value) { $value_num = $num_func($value); if (null === $max_num || $value_num >= $max_num) { $max = $value; $max_num = $value_num; } } return $max; } $c = max_by([1, 2, 3], function(int $a): int { return $a + mt_rand(0, $a); }); echo $c;', 'error_message' => 'InvalidArgument', ], 'impureCallableReturn' => [ ' 'InvalidReturnStatement', ], ]; } }