If you want any evidence that terrible language design is alive and well in PHP, look no further than the new array_find function.
Not only is it yet another global function in a namespace already chock full of random array helpers, it is extremely similar in both name and usage to array_search - a global function since PHP 4. Except, of course, that in typical PHP fashion, array_find’s argument order is ($array, $filter_callback) while the older array_search is ($search_value, $array).
There are literally hundreds of hits for existing, global, functions named array_find. If these are loaded from a library, they will break uses of the new built-in function in exciting ways. Yet, even with this mentioned in the RFC (https://wiki.php.net/rfc/array_find) it seems to have been no obstacle whatsoever to its inclusion - despite the fact that the implementation is literally three lines of code.
I’m one of the release managers for PHP 8.4 (I didn’t tag myself as author though, and I should probably update my hats). Ask me anything about PHP 8.4 I guess.
Is there more background / numbers on the JIT work?
The lazy object stuff seems a little niche. Does it really benefit DI if applied broadly, or is it more for manual marking of classes with expensive init?
I love some of these changes! I was joking with some friends of mine this morning that with every PHP release it inches closer and closer to C#. Is C# and the broader “enterprise” OOP world one of the big inspirations for some of these changes that get included in these releases?
Also not about this change but is it really that hard to get Generics into PHP?
There’s some stuff C# doesn’t have (but I haven’t touched it in years, so I might be wrong) like rudimentary ad-hoc sum types (i.e. string|Callable). I think it’s more a general PLT zeitgeist thing; you see a lot of the same forces driving Kotlin, Swift, etc.
Fatal error: Uncaught ErrorException: Symfony\Component\Console\Input\ArgvInput::__construct(): Implicitly marking parameter $argv as nullable is deprecated, the explicit nullable type must be used instead in phar:///shared/backups/php/deployer-7.5.phar/vendor/symfony/console/Input/ArgvInput.php:46
Not going to lie. As an old PHP 4 user, seeing all these long and dense code examples, with a weird obsession to wrap everything in classes, saddens me a little.
PHP used to be the low profile ghetto kid that, after first impressions, actually meant business.
Setting up a database connection? No problem, it even included connection driver in the core. Serving HTTP? Trmplating HTML? No worries that’s what it was made for.
All this stuff was simple.and direct. The main non basic data structure was like a Swiss Army Knife, an array, a list a map… Reflex? No worries, full PCRE support.
Unlike other commenters, I actually think it’s refreshing to see a function thrown in the top namespace presented here as a new feature. It has that non orthodox yet effective feel to it. Ghetto style.
The whole focus on classes, type annotations, dependency injection, auto loading plugins, all this is just annoying noise for me. I think the project lost its old ways, from when it was king.
I wonder if a bunch of us die hards would put together something in the spirit of 90-2000s PHP, what would it look like.
For what is worth, I still use PHP the old way every now and then when creating quick and dirty UIs for limited time usage. It is still the easiest way to do it.
New DOM API that includes standards-compliant support for parsing HTML5 documents, fixes several long-standing compliance bugs in the behavior of the DOM functionality, and adds several functions to make working with documents more convenient.
That is very cool and lol that it wasn’t in PHP before now.
Fantastic comment on the other site about array searching functions in the standard library:
Complete with entirely predictable ‘it’s never been a problem for me so why should it ever be a problem for anyone’ response!
I agree that the existing standard library is a lost cause and building on top of it will only create friction.
In my code I avoid the built-in array/string functions (almost) entirely, and instead use Laravel’s helpers, which are way more convenient:
I’m one of the release managers for PHP 8.4 (I didn’t tag myself as author though, and I should probably update my hats). Ask me anything about PHP 8.4 I guess.
Congrats on another great release!
Is there more background / numbers on the JIT work?
The lazy object stuff seems a little niche. Does it really benefit DI if applied broadly, or is it more for manual marking of classes with expensive init?
Any personal favourites this release? :)
I’m not as familiar with the JIT or lazy objects, so I’ll defer there.
Database extensions are close to my heart, so the PDO changes should make those nicer.
I love some of these changes! I was joking with some friends of mine this morning that with every PHP release it inches closer and closer to C#. Is C# and the broader “enterprise” OOP world one of the big inspirations for some of these changes that get included in these releases?
Also not about this change but is it really that hard to get Generics into PHP?
There’s some stuff C# doesn’t have (but I haven’t touched it in years, so I might be wrong) like rudimentary ad-hoc sum types (i.e.
string|Callable). I think it’s more a general PLT zeitgeist thing; you see a lot of the same forces driving Kotlin, Swift, etc.Flags to make it php7.3 compatible?)
What BC changes in 7.3 affected you?
Check out “impact analysis and migration paths”:
https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
Not going to lie. As an old PHP 4 user, seeing all these long and dense code examples, with a weird obsession to wrap everything in classes, saddens me a little.
PHP used to be the low profile ghetto kid that, after first impressions, actually meant business.
Setting up a database connection? No problem, it even included connection driver in the core. Serving HTTP? Trmplating HTML? No worries that’s what it was made for. All this stuff was simple.and direct. The main non basic data structure was like a Swiss Army Knife, an array, a list a map… Reflex? No worries, full PCRE support.
Unlike other commenters, I actually think it’s refreshing to see a function thrown in the top namespace presented here as a new feature. It has that non orthodox yet effective feel to it. Ghetto style.
The whole focus on classes, type annotations, dependency injection, auto loading plugins, all this is just annoying noise for me. I think the project lost its old ways, from when it was king.
I wonder if a bunch of us die hards would put together something in the spirit of 90-2000s PHP, what would it look like.
For what is worth, I still use PHP the old way every now and then when creating quick and dirty UIs for limited time usage. It is still the easiest way to do it.
That is very cool and lol that it wasn’t in PHP before now.
What are some of the new security features? And does it see a large performance increase?