PHP 8 changes – my first impressions
PHP 8 in out since 26 Nov 2020.
I took a look at the change log and here is what I like and don’t like. Most of them are great changes.
1. Named arguments
![](https://liviuoprisan.com/wp-content/uploads/2021/01/4ba2bbdc-e030-4ad8-8a37-c9fa52af1206.jpg)
This is nice. I think I’ve seen this in Kotlin before.
2. Annotations
![](https://liviuoprisan.com/wp-content/uploads/2021/01/b83c0fd6-6b50-4b74-976d-f8dfe408311c.jpg)
This is excellent.
The fact that PHP didn’t have native annotation was one of the main reasons I preferred java.
Remains to be seen if it’s just as useful as it is in java or if it has some drawbacks.
I preferred the @ notation but I guess there were some constrains that prevented that.
Maybe the error suppression in PHP suing the same symbol.
3. Constructor helper
![](https://liviuoprisan.com/wp-content/uploads/2021/01/21c68e65-7cf8-469e-9ac8-518eca03bba7.jpg)
This looks useful. I think I’ve seen it in Typescript before.
4. Union types
![](https://liviuoprisan.com/wp-content/uploads/2021/01/5c107015-9bb3-4f97-83af-eae6201e6976.jpg)
I think I prefer just one type per variable.
5. Match expression
![](https://liviuoprisan.com/wp-content/uploads/2021/01/b506a6a4-6a19-48ec-b6b3-35319c943381.jpg)
I hate this. From what I understand it’s also in Rust.
6. Nullsafe operator
![](https://liviuoprisan.com/wp-content/uploads/2021/01/7b318f9d-9286-4976-967d-1709a4198b62.jpg)
I love this one.
7. Saner string to number comparison
![](https://liviuoprisan.com/wp-content/uploads/2021/01/48884ac1-a290-4760-8d60-9b89e7385f93.jpg)
Haha, about time.
8. Trailing comma in parameter lists
![](https://liviuoprisan.com/wp-content/uploads/2021/01/70a0d3ec-4c6a-49b3-bc22-2195054ad536.jpg)
Very nice. It will improve PHP developers mental sanity. I hate errors about that comma.