[PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening)
[Posted February 13, 2015 by corbet]
| From: |
| Andrea Faulds <ajf-AT-ajf.me> |
| To: |
| PHP internals <internals-AT-lists.php.net> |
| Subject: |
| [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) |
| Date: |
| Sun, 13 Jul 2014 02:57:28 +0100 |
| Message-ID: |
| <08503591-EFC8-48E6-984E-FFC292C5EA5F@ajf.me> |
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/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php