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.
Designer, developer, and strategist obsessed with what happens after someone lands on a website. I write about CSS, UX friction, production-ready sites & more.
Designer, developer, and strategist obsessed with what happens after someone lands on a website. I write about CSS, UX friction, production-ready sites & more.
Designer, developer, and strategist obsessed with what happens after someone lands on a website. I write about CSS, UX friction, production-ready sites & more.
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 and array_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, like array_find_key and array_find. Of course the old key value equivalents will stay as they are, like key_exists and in_array.
💻 Tech Enthusiast | Linux & Open Source Explorer
🔧 Sharing insights on Ubuntu, Debian, Docker, and DevOps tools
🐍 Passionate about Python, SQL & MySQL
✍️ Writing tutorials, guides, and answers to m
Designer, developer, and strategist obsessed with what happens after someone lands on a website. I write about CSS, UX friction, production-ready sites & more.
Designer, developer, and strategist obsessed with what happens after someone lands on a website. I write about CSS, UX friction, production-ready sites & more.
Designer, developer, and strategist obsessed with what happens after someone lands on a website. I write about CSS, UX friction, production-ready sites & more.
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...
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_firstandarray_key_lastfunctions. 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_keyandarray_find. Of course the old key value equivalents will stay as they are, likekey_existsandin_array.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.
Good!
“Closures in Constant Expressions” Hell Yeah!