mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Prevent usage of callable objects in ReflectionFunction::__construct()
As per @weirdan's feedback, we can prevent the usage of `object` instances that implement `__invoke()`, as well as `array` callables, by declaring the ctor argument of `ReflectionFunction` to be either a real `Closure`, or a `callable-string`. While this may not be 100% of scenarios, it is a healthy way to identify errors in userland. Ref: https://github.com/vimeo/psalm/pull/8722#discussion_r1027151421
This commit is contained in:
parent
d5cccbade2
commit
d9a0cc5311
@ -432,7 +432,11 @@ abstract class ReflectionFunctionAbstract implements Reflector
|
||||
|
||||
class ReflectionFunction extends ReflectionFunctionAbstract
|
||||
{
|
||||
/** @psalm-pure */
|
||||
/**
|
||||
* @param callable-string|Closure $function
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function __construct(callable $function) {}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user