Adapted from comment by "Daniel dot L dot Wood at Gmail dot Com" on PHP documentation site:
http://php.net/manual/en/language.oop5.typehinting.php#83442
Developers often want scalar/basic type hints. This drop-in class enables type hints through the use of a custom error handler.
Why?
- Developers are sick of using the is_* functions to validate parameters.
- Reduction of redundant coding for defensive coders.
- Functions and methods become self-defining and self-documenting as to required input.
Note: You should include this code above all other code in your include headers and if you are the using set_error_handler() function you should be aware that this uses it as well. You may need to chain your set_error_handlers()
Also: Follow the typehint discussions on the PHP Internals boards.