Rome, they say, was not built in a day. PHP is marching on. Leading in some areas, catching up on others. Making progress. Thanks Brent.
@phpannotated
Ай бұрын
Very true!
@duncanmcclean
Ай бұрын
The concept of something in PHP that always returns an element’s key and value would be great! Something I never thought I needed but would be super useful.
@stephenbetley9596
Ай бұрын
Another step forwards for descriptive programming. 😀
@LuisEduardoBraschi
Ай бұрын
7:18 A tuple. C# has KeyValuePair.
@phpannotated
Ай бұрын
Gotcha! I meant more like a dedicated type for specific tuples
@kishandhankecha
Ай бұрын
@@phpannotated Dart has MapEntry
@phpannotated
Ай бұрын
@@kishandhankecha I love that!
@roeyco83
Ай бұрын
Current string and array handling is a disorganized mess. Implementing them as dedicated classes, similar to how mysqli has its own class, would be a significant improvement.
@CaptainFalcon92
Ай бұрын
Why they keep adding these root prefixed function I cannot explain. This is an annoying legacy I wish to see gone. I'm still hoping for a native Array object with true methods. It's a shame we still need librairies when you consider how all contenders have had the Array object for ever. Native $myArray->filter()->map() is all we ask for. Meanwhile I keep utilizing Doctrine's ArrayCollection :/ but it's incomplete
@myPrzeslaw
Ай бұрын
Preach!
@pixtweaks393
Ай бұрын
Keep it simple! No OOP is necessary for such a simple things. And kindly reminder, OOP is slower and consumes more memory...
@myPrzeslaw
Ай бұрын
@@pixtweaks393 Well, no OOP is in fact NECESSARY for anything. You can even write everything in plain assembler - efficient and memory-friendly. And yet, we tend not to. The reality, however, shows that chaining multiple atomic array operations (instead of assigning temporary results to unnecessary temporary variables, or even worse - nesting calls of multiple array functions) is far cleaner, more readable, and a lot simpler. So no - we can't KEEP it simple. Instead - let's MAKE it simple! The point is - using custom Collections or even writing your own by implementing ArrayAccess interface and basically copy-pasting all the necessary array_* functions is slower and less memory-friendly than having that option available on a language level. If developers tend to bypass some element of their own language it tells something about that element. PHP 2024 looks great, but unchainable arrays combining indexed and associative datasets in the same tool is really an infamous relic of the past. If someone wants to stick to it be my guest, but there's no reason not to to give the rest of us the opportunity to use efficient Collection and Set objects provided on the language level.
@medilies
Ай бұрын
Nikita created an experimental extentions that does that.
@robjanssen7420
Ай бұрын
@@pixtweaks393 the loss in performance pales in compares to the gain in readability. array_map and array_filter and usort all have wildly different syntaxes and under the hood it would be trivial to turn it into procedural things with immutability by default (which is not the case for usort).
@medilies
Ай бұрын
I would prefer if they named array_all array_every just like in JS.
@geoffreyvanwyk4588
Ай бұрын
Yes, it would fit English better. "Every element matches this condition." "Every" refers to the individual element. On the other hand, "all" refers to the array as a whole. Very disappointing failure, if not epic. But it fits in with PHP's history of messing up naming.
@pixtweaks393
Ай бұрын
I'm missing array_contains or array_value_contains. You guessed it, loop thought all (string) values and if it contains needle returns true, otherwise false. Well, for PHP 9.2 maybe? :
@Kleberei
Ай бұрын
You mean in_array?
@pixtweaks393
Ай бұрын
@@Kleberei No, in_array() has to be equal value to match, not just a fragment i'm talking about
@crazyingenieur3277
Ай бұрын
Does anyone know the link to the official schedule of 8.4, from alpha to GA, which I believe is some time in November?
@phpannotated
Ай бұрын
Here you go :) wiki.php.net/todo/php84
@crazyingenieur3277
Ай бұрын
Thank you!
@shyamendrahazra3440
14 күн бұрын
PHP detected subscription confirm
@phpannotated
13 күн бұрын
This is the way.
@CottonInDerTube
Ай бұрын
Shouldnt array_find return an array of findings? I mean array_find_key obviously not. But values are not unique. array_any would even indicate that array_find is returning an array of found values (note: the callback may not just return true for one value). EDIT: array_find should act like array_filter: return an array of matches. Done. But ... why not use array_filter in the first place =)
@phpannotated
Ай бұрын
I guess array_find is implemented to laravel's array_first, what you're describing could be another RFC, array_find_all - which would be useful as well
@icantchosemyname
Ай бұрын
IMHO *.find() methods should generally returns a unique value from the array. As you said *.filter() is the one that should return a sub array. That's the case in laravel too. It feels like a convention.
@brunoggdev6305
Ай бұрын
@@icantchosemyname Exactly
@medilies
Ай бұрын
Imagine it like: SELECT * FROM array WHERE callback LIMIT 1. Also most of the new API is implementing functions that already exist in Javascript and that is how find behaves in JS.
Пікірлер: 33