DEV Community

Discussion on: PHP 8 in 8 code blocks

Collapse
 
moopet profile image
Ben Sinclair

This is the first I've seen of these, and I worry that they're... well, they're not all good things. For one thing, there's a lack of simple progression: you can't look at them all with knowledge consisting mostly of previous PHP syntax and guess what they'll do.

Attributes are probably a good thing. I mean, anything to get away from the practice of annotating things with comments, which is used by a bunch of frameworks at the moment. Shudder.

"mixed" means... well, something. Is it there just to take up space, because the parser now requires a type? That's fine, but the linked explanation suggests it can be null but can't be nullable and that it is there because, for one thing, Bad Old PHP might have returned null instead of a known type. That means nothing to me.

"static" is already overloaded. It's getting another use? Cool. Why not. YOLO.

"throw can be used in expressions." - I didn't realise it couldn't. I think that writing exceptions into expressions is Straying Too Far From The Path, though, so I probably never tried.

"Non-capturing catches"? Reasonable.

"Trailing commas are allowed in parameter lists"? Good, I guess. It's a non-breaking update that will make it more consistent with arrays.

"New string functions". Oh come on, PHP. Stop adding millions of inconsistent functions that are there to replace... well, other functions. This is already way too sugary.