Type hinting is a feature introduced in PHP 5 that lets developers specify the type of the parameters expected by each function.
This way, application bugs may be detected earlier, when they pass function arguments of the wrong type.
Unfortunately, the current type hinting implementation only supports verification of parameters that are objects, and more recently arrays.
This package provides a solution to overcome this limitation by enabling also the verification of arguments of basic types like integer, string, float, etc..
This way type hinting can become more useful to detect bugs in broader range of applications with class functions that take basic type values as arguments.
This package implements the support for type hinting that works with PHP base data types.
It works by replacing the current PHP error handler that performs enhanced type checking of the types of parameters when functions are called.
Several classes are provided to perform type checking of parameters of base types: boolean, float, integer, string, resource, callable.
There are additional classes for strict type checking of float and string values. These classes do not accept values of other types that could be promoted to types: integer float or string.
When the replacement error handler catches a recoverable error that corresponds to type checking mismatch, it checks the function declaration and calls the type checking class correspondent to the expected type of the parameter that triggered the error.