Re: [RFC] First-class callable syntax
| From: | Ondřej Mirtes | Date: | Thu, 20 May 2021 14:16:51 +0000 |
| Subject: | Re: [RFC] First-class callable syntax | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-114533@lists.php.net to get a copy of this message | ||
Hi, I’m confused by the syntax, when I read it, I think to myself “I know
this, this is just a method call… oh wait, it’s actually a callable”. It
really makes my head hurt.
Also, static analysers already have to reason about current code, so
PHPStan (and Psalm probably too) already supports referencing to callables
as strings (global functions) and arrays (methods):
$name = 'date';
$name(1); // Parameter #1 $format of callable 'date' expects string, int
given.