4 ms·
I stand corrected. PHP does not have type hint for their internal datatypes (int, float, string). Only array is supported. Type hinting for your custom datatyp
by birkbork 12y ago
I stand corrected.
PHP does not have type hint for their internal datatypes (int, float, string). Only array is supported. Type hinting for your custom datatypes is supported, when used as function arguments.
Also hack introduces type hint for function return type.
- TazeTSchnitzel 12y agoScalar (int, float, string) type hinting may be added in a future PHP version, and there's currently an RFC for return types (I expect it'll pass myself). PHP already let you type hint for classses.
- birkbork 12y agoCool! I wasn't aware of the RFC. Must be this one then? https://wiki.php.net/rfc/returntypehinting https://wiki.php.net/rfc/returntypehinting
- TazeTSchnitzel 12y agoYep.
- spaux 12y agoYou can also hint on interfaces. If strict typing is important, I use the SPL primitive wrapper classes like SplString or SplInt http://php.net/manual/en/class.spltype.php http://php.net/manual/en/class.spltype.php