[RFC] Support for <func>::function syntax
| From: | as@php.net | Date: | Sat, 07 Nov 2020 23:41:22 +0000 |
| Subject: | [RFC] Support for <func>::function syntax | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-112201@lists.php.net to get a copy of this message | ||
Hello internals,
Looking for feedback on the idea of supporting
::function syntax (or
::fn) for consistency with existing ::class syntax:
$arr = ['apple'];
print_r(array_map(strtoupper::function, $arr));
(Apologies if this has already been discussed. Hard to search for
colon-colon-function.)
Benefits in my view are readability and potential use in static analysis.
Downsides (as implemented in proof-of-concept) are that it can be
needlessly littered in a lot of places, and that it breaks class consts
named function. I'd vote against it in its current state, but if people
like the general idea maybe the drawbacks can be addressed with a better
implementation.
Examples:
https://gist.github.com/adsr/2c0b9243986418af3cecf8046657304b
Proof-of-concept:
https://github.com/adsr/php-src/commit/07bb24243022ccef5823f6977d231f3535a48a07.patch
Adam