[RFC] Scalar Type Hinting With Casts (re-opening)
| From: | Andrea Faulds | Date: | Sun, 13 Jul 2014 01:57:28 +0000 |
| Subject: | [RFC] Scalar Type Hinting With Casts (re-opening) | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-75383@lists.php.net to get a copy of this message | ||
Good evening,
PHP’s type hinting system is rather incomplete as it does not support scalars, only arrays,
callables and objects. In 2012, Anthony Ferrara created an RFC which proposed type hinting for
scalar types (int, float, bool, string and resource) with casting, with behaviour nearly the same as
that of zend_parse_parameters. Sadly, he later left PHP internals and withdrew his RFCs.
Since I am very much in favour of scalar type hints, I’ve updated the patch to master and made
some minor improvements, and I am re-opening the RFC with the intent to try and get it into PHP 5.7.
The patch is mostly there. It needs some more tests and there are some edge cases I need to deal
with, but it otherwise works, and I expect I can finish fixing it up very soon.
The RFC is here: https://wiki.php.net/rfc/scalar_type_hinting_with_cast
A pull request is here: https://github.com/php/php-src/pull/717
I’m hoping I can get this into PHP 5.7. I think scalar type hinting would be a valuable addition
to PHP’s existing type hinting system.
Thanks!
--
Andrea Faulds
http://ajf.me/