News for hackers. Stuff that matters.
Re:Stop Using Pseudo-Types by pwdisswordfishy on Monday February 02, 2026 @03:57AM (#46853870)
Why? The article fails to explain.

> 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.

Re:Stop Using Pseudo-Types by donatj on Monday February 02, 2026 @06:31AM (#46854794)
Exactly. The article kind of circles around the idea that it's bad, but never really lands on why.

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

Re:Stop Using Pseudo-Types by joe_hoyle on Monday February 02, 2026 @08:36AM (#46855879)
The problem is that first class callables actually makes a new object wrapper for each reference, so trim(…) != trim(…). (It can be true in some cases, it depends if the memory is freed for the first reference).
Re:Stop Using Pseudo-Types by pwdisswordfishy on Monday February 02, 2026 @10:40AM (#46857212)
And how is Closure::fromCallable('trim') recommended by the article any better in that respect?

    $ php8.4 -r "var_dump(Closure::fromCallable('trim') === Closure::fromCallable('trim'));"
    bool(false)
Re:Stop Using Pseudo-Types by joe_hoyle on Monday February 02, 2026 @12:06PM (#46858338)
It is not better, this is a problem with the first-class callable syntax altogether.