
The Developer-Friendly Upgrade You’ve Been Waiting For
PHP 8.5 is out soon, and honestly, it’s one of those releases that makes me excit...
For further actions, you may consider blocking this person and/or reporting abuse
Finally, array_first and array_last! 🙌 Great article, @web_dev-usman
I'm trying to wrap my head around the implications of closures in constants. My biggest concern is that it might encourage improper usage, leading to code with undefined or leaky boundaries.
Every feature has the possibility of improper usage.
I think the example is not the most useful one. The more useful example is when the closure is paired with an attribute.
Instead of having to create a one-of function or instance somewhere in the application, it is now possible to do it as an attribute argument.
you can see more examples here.
Thanks for your feedback.
Thanks...
Nice post! PHP 8.5 looks great, pipe operator, array helpers, and better error stack traces will make life way easier.
Glad you liked it.
It's pretty obvious from the examples that this has been copied from one of Nuno's posts. It would be nice to give him credit.
Of course, I took inspiration from different people in my writing. This is called research of topics.
PHP 8.5 is bringing some amazing quality-of-life updates.
Which one excites you the most?
array_first and array_last, surprisingly I can't think when I need this kind of functions, but it's nice to have.
The only use case i can think of is when you need to keep the array as is, but you want the first or last value to prepend or append the array.
I think I is more to have a value equivalent for the
array_key_first
andarray_key_last
functions. It creates a consistency a lot of people think is lacking in PHP. When new array functions are added there is a key and a value equivalent, likearray_find_key
andarray_find
. Of course the old key value equivalents will stay as they are, likekey_exists
andin_array
.“Closures in Constant Expressions” Hell Yeah!
Good!