Re: [RFC] [Discussion] Prefix and Suffix Functions

From: Date: Fri, 23 Jan 2026 10:32:04 +0000
Subject: Re: [RFC] [Discussion] Prefix and Suffix Functions
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-129883@lists.php.net to get a copy of this message
On Fri, 23 Jan 2026 at 09:31, Tim Düsterhus <tim@bastelstu.be> wrote: > Hi > > Am 2026-01-22 19:28, schrieb Barel: > > Following a comment by Tim Düsterhus (thanks!) and another comment in > > the > > PR, I have inverted the order of the parameters in the ensure and > > remove > > functions, so that they follow the parameter order in related functions > > like str_contains() and str_starts_with() > > Thank you. I have given the RFC another look and have some polishing > comments: > > 1. In the “Exact semantics (per function)” example it would probably be > easier to understand if you would provide a userland implementation. > Folks are already used to reading PHP and there is no ambiguity about > the proposed behavior then. As a benefit, the implementation from the > RFC would directly be usable as a polyfill, e.g. for use in > https://github.com/symfony/polyfill. The previous > “array_find” RFC might > be a good example here: https://wiki.php.net/rfc/array_find > > 2. In the “Backwards Incompatible Changes” section: Can you please > perform some research for a rough number estimation? e.g. using GitHub's > code search. > > ------ > > Another thing I realized is the interaction between the > _replace > functions and PFA: It can be used as an (inefficient?) way of creating a > concat as a function handle: $concat = str_prefix_replace("", ?, > ?); > (with suffix_replace being a reverse concat). > > Best regards > Tim Düsterhus > Tim, thanks for your suggestions, I updated the RFC Cheers Carlos

« previous php.internals (#129883) next »