Re: A little syntactic sugar on array_* function calls?

From: Date: Tue, 25 May 2021 10:09:33 +0000
Subject: Re: A little syntactic sugar on array_* function calls?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-114574@lists.php.net to get a copy of this message
On Tue, May 25, 2021 at 11:31 AM Hans Henrik Bergan <divinity76@gmail.com> wrote: > fwiw this can be implemented in userland, and i bet someone already made a > composer package for it ^^ > Not everyone is interested in doing `$array = new ArrayWrapper($originalArray) and then breaking all array` parameters. There are a bunch of different packages and people prefer different packages on top of that. Some packages will have feature X and others will have feature Y, and that makes it even harder to properly use. The downside of having this in PHP will obviously be that it's much less flexible than a userland implementation. I'd be very happy to see it in PHP while I won't even bother looking for array wrappers in userland. On Tue, May 25, 2021 at 12:05 PM someniatko <someniatko@gmail.com> wrote: > There is Pipe Operator RFC existing already, which most probably would > suit your needs. The code you want will look like this: > https://wiki.php.net/rfc/pipe-operator-v2 > > ```php > $array |> array_map($somefunction). > ``` The pipe operator feels like a poor solution while -> would do exactly what people want. On Tue, May 25, 2021 at 12:05 PM someniatko <someniatko@gmail.com> wrote: > > I was wondering whether $array->map($somefunction) would be possible. > > There is Pipe Operator RFC existing already, which most probably would > suit your needs. The code you want will look like this: > https://wiki.php.net/rfc/pipe-operator-v2 > > ```php > $array |> array_map($somefunction). > ``` > > Best wishes, > someniatko > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >

« previous php.internals (#114574) next »