RE: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening)

From: Date: Sun, 20 Jul 2014 16:26:46 +0000
Subject: RE: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening)
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-75722@lists.php.net to get a copy of this message
On 18 Jul 2014, at 14:09, Andrea Faulds <ajf@ajf.me> wrote: > I’ve updated the RFC and patch to make int, string and double nullability work like the other > types (bool already did). If the default value isn’t NULL, NULL isn’t accepted and you’ll get > E_RECOVERABLE_ERROR. If the default value is NULL, NULL is accepted and will not be casted. > > This will likely lead to less bugs as NULL is a common error value, and it also makes the > scalar type hints more consistent with the others. Thank you very much for making this change. It goes a long way towards making scalar type annotations more useful to me as a userland developer. Also, I really like the new "numeric" type hint. The one remaining issue I have with this proposal is that boolean values are currently accepted for every other scalar type except array. As with NULL, FALSE is a common error value, and allowing booleans to be passed to a function expecting a string or numeric value could easily mask errors and lead to hard-to-debug issues in a program. Just as a string cannot be passed to a function expecting a boolean, a boolean should not be passed to a function expecting a string, etc. Thanks for all you do for the community. -- Theodore Brown A PHP developer interested in the future of the language

« previous php.internals (#75722) next »