Re: Array arguments for str functions

From: Date: Mon, 16 Mar 2026 16:51:25 +0000
Subject: Re: Array arguments for str functions
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-130366@lists.php.net to get a copy of this message
On Mon, 16 Mar 2026 at 15:32, Tim Düsterhus <tim@bastelstu.be> wrote: > 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 > Tim, Morgan Thanks for your comments. I did not realise that this would be easily implemented by using array_any. This means that the RFC that I was planning to create is not actually needed Cheers Carlos

« previous php.internals (#130366) next »