In a new post to his site Thijs Feryn has shared an overview of the different types of type errors that can pop up in PHP 7. This includes both a text-based and video based versions depending on your preference.
PHP 7 has a concept called Type Errors. These errors are thrown on a type mismatch when interacting with functions. They can be caught just like exceptions. I created a video that explains the situation. This blog post goes into more detail and has some code examples.
The post gets into the details of the type errors including topics like:
- new type hints that were introduced
- how you can manually throw type errors
- when PHP itself would throw the errors
- type coercion
There's also a brief section about strict typing and how that changes what errors PHP might throw in your scripts.