Union types: PROs and CONs
Union types provide the same advantages as type hinting, even when you need to allow
more than one type. This definitely helps improve your code readability and quality.
The question is: is PHP going to enforce strict typing more in the future? On the one hand, union types let you use type hinting more often than before. On the other hand, they remove the need to choose a single type for each argument (or for the return value) for developers who want to use type hinting.
So, it's not 100% clear if more or less strict typing rules can be expected in the future. What do you think?
|