[php-src] Issue #14385: First class callable for instance methods
| From: | rela589n | Date: | Fri, 31 May 2024 10:07:46 +0000 |
| Subject: | [php-src] Issue #14385: First class callable for instance methods | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-246992@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14385
Author: rela589n
### Description
Hi there!
I would like to propose following syntax sugar:
```php
/** @var SurveyTemplate[] $templates */
$templateIds = array_map(SurveyTemplate::getId(...), $templates);
```
As the replacement for more verbose instance method call:
```php
/** @var SurveyTemplate[] $templates */
$templateIds = array_map(static fn (SurveyTemplate $surveyTemplate): Uuid =>
$surveyTemplate->getId(), $templates);
```
Currently, first class callable methods allow to wrap only static method, while in current place
non-static method is suggested to use.
Please, let me know what you think about it.