by krick · 6d ago · 0 comments
Not a huge fan of partial function application syntax. Was it really necessary when you already have short anonymous function? What does it cost you to write that explicitly? Like, 10 extra characters? It is way more readable and clear what you mean when a variable has a name, not just `?`. WTF is `?`?
Pretty much the same for DocComments for params. Uh... why? I don't see anything wrong with the old way.
Duration class... well, we all already had duration classes in our projects, didn't we? It looks alright, but it's a real pity operator overloading isn't a native part of the language still. Why do we still have to `->add()` instead of `+`?
Similarly harmless but not hugely exciting are `clamp()` and `SortDirection`. The former isn't that hard to implement, but I don't think I ever did somehow, so thank you. SortDirection is literally just a built-in enum, not a huge deal. Libraries will still use their own implementations for a long time just to preserve back-compatibility.
Polling... Well, I'd usually opt for some other language instead of using PHP like that, but sometimes you need it.
Stream Error Handling and Readonly Defaults are great and overdue.
All in all, doesn't look to be a terribly exciting update.
The given example is 26 additional characters, and that's without any type declarations. Also calling closures isn't free, there is a small performance penalty.
fn ($version) => version_compare($version, '8.6', '>=')
vs version_compare(?, '8.6', '>=')
> Pretty much the same for DocComments for params. Uh... why?The reason is that docblocks are used to attach meta data to code, like generics.
> SortDirection is literally just a built-in enum, not a huge deal. Libraries will still use their own implementations for a long time just to preserve back-compatibility.
Symfony at least conditionally defines a SortDirection enum in the global namespace: https://github.com/symfony/polyfill-php86/blob/1.x/Resources...