This is an old revision of the document!
Request for Comments: Parameter Type Casting Hints
- Version: 0.1
- Date: 2012-03-03
- Author: Anthony Ferrara firstname.lastname@example.org
- Status: In Draft
- First Published at: https://wiki.php.net/rfc/parameter_type_casting_hints
Currently, PHP has no way to provide type hinting for function parameters which are not classes or arrays. This is on often requested feature that has been discussed on the internals list many many times. This RFC discusses one implementation of this feature that still attempts to remain in the spirit of PHP's dynamic type nature.
This RFC discusses a method of adding scalar type hints to PHP while attempting to embrace the dynamic nature of PHP variables. This means that passing a type that does not match the hinted type will cause a cast to happen (if possible, based on the normal type-casting rules used in other areas of the engine).