Stop Using Pseudo-Types
f2r.github.io
f2r.github.io
> The introduction of first-class callables simplifies callback handling. You no longer have an excuse to define your callbacks like this:
> <?php
> $data = array_map(trim(...), [' x', 'z ']);
“First-class callables” is that exact syntax.
My experience is with modern annotations, callable and iterable are pretty powerful, convenient, and safe.
- https://phpstan.org/writing-php-code/phpdoc-types#callables
- https://phpstan.org/writing-php-code/phpdoc-types#iterables
$ php8.4 -r "var_dump(Closure::fromCallable('trim') === Closure::fromCallable('trim'));"
bool(false)