alt.hn

1/28/2026 at 1:36:09 PM

Stop Using Pseudo-Types

https://f2r.github.io/en/stop-using-pseudo-types.html

by speckx

2/2/2026 at 8:57:21 AM

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.

by pwdisswordfishy

2/2/2026 at 1:36:00 PM

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

by joe_hoyle

2/2/2026 at 3:40:23 PM

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)

by pwdisswordfishy

2/2/2026 at 5:06:46 PM

It is not better, this is a problem with the first-class callable syntax altogether.

by joe_hoyle

2/2/2026 at 11:29:21 AM

Stop using languages where strings are callable :-p

by nilslindemann

2/2/2026 at 3:42:29 PM

I think the point of introducing the (...) syntax that for some reason this article apparently denigrates (if I even understand it correctly) is to eventually deprecate that.

by pwdisswordfishy

2/2/2026 at 6:05:57 AM

[dead]

by boycothn