Re: Array arguments for str functions

From: Date: Mon, 16 Mar 2026 14:30:11 +0000
Subject: Re: Array arguments for str functions
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-130363@lists.php.net to get a copy of this message
Hi Am 2026-03-16 01:41, schrieb Morgan:
For this extension, I'm not sure what the advantages are over simple function composition (array_any was introduced for exactly this sort of job and is applicable to any function)
I agree. Especially since the Partial Function Application RFC was accepted an ad-hoc implementation would just be:
    $str = 'bazinga';
    $strStartsWithAny = \array_any(['foo', 'bar', 'baz'], \str_starts_with($str, ?));
I have also added an optimization to PHP 8.6 that compiles array_map() into a foreach loop when the callback is first class callable or PFA: https://github.com/php/php-src/pull/20934. I plan to extend this to the other array_* functions once the PFA PR is merged. Best regards Tim Düsterhus

« previous php.internals (#130363) next »