Re: [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters
| From: | Lazare Inepologlou | Date: | Mon, 12 Mar 2012 12:17:17 +0000 |
| Subject: | Re: [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-58870@lists.php.net to get a copy of this message | ||
Hello Anthony,
I will raise once again the question about accepting null. According to
your POC, null is an acceptable value if it is also declared as a default
value. This is problematic for the scalar types, because they can very well
have a different default value.
An example: There is a check box with three states (check, unchecked and
mixed). This is usually translated to a three state boolean (true, false
and null). The default value of the check box is false.
function set_check_box_state( bool state = false ) { ... }
set_check_box_state( null ); // null will be converted to false here...
Therefore, this cannot work, unless the default value becomes null, which
is against the requirements. What I suggest is something like this:
function set_check_box_state( bool? state = false ) { ... }
set_check_box_state( null ); // works fine
In my opinion this is much clearer, as it separates the notions of the type
and that of the default value.
Lazare INEPOLOGLOU
Ingénieur Logiciel