On Mar 4, 2012 11:47 AM, "Lazare Inepologlou" <linep...@gmail.com> wrote: > > > Anthony, just a tiny detail in your RCF: > >> So (int) $foo = null and (int) $foo = 1 are both supported, but (int) $foo = “1” will generate an E_COMPILE_ERROR. > > > If null is going to be cast, (int)null is 0. So I don't think it should be a valid default value.
Well, there were two reasons that I added null: first, for consistency with the existing type hints. Second, and more importantly, to allow checking if a parameter is specified. So without null, you couldn't tell the difference between an explicit 0 and an implicit (not specified) 0. This way, you can. I admit the use cases for that are rather slim, but a good portion of internal functions behave this way (substr comes to mind)... I think it is worth discussing further, as your point is indeed valid... > > Lazare INEPOLOGLOU > Ingénieur Logiciel > > > 2012/3/4 Anthony Ferrara <ircmax...@gmail.com> >> >> Hey all, >> >> I've drafted an RFC for the Parameter type casting hint proposal that >> I posted to before. Attached to the RFC is a patch that's proposed >> for inclusion in core for functionality (it doesn't include news >> entries, or documentation, or any of the other steps that would be >> needed prior to commit). >> >> https://wiki.php.net/rfc/parameter_type_casting_hints >> >> Please provide feedback here on the implementation and RFC topics. >> >> Thanks, >> >> Anthony >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> > On Mar 4, 2012 11:47 AM, "Lazare Inepologlou" <linep...@gmail.com> wrote: > > Anthony, just a tiny detail in your RCF: > > So (int) $foo = null and (int) $foo = 1 are both supported, but (int) $foo >> = “1” will generate an E_COMPILE_ERROR. >> > > If null is going to be cast, (int)null is 0. So I don't think it should be > a valid default value. > > > Lazare INEPOLOGLOU > Ingénieur Logiciel > > > 2012/3/4 Anthony Ferrara <ircmax...@gmail.com> > >> Hey all, >> >> I've drafted an RFC for the Parameter type casting hint proposal that >> I posted to before. Attached to the RFC is a patch that's proposed >> for inclusion in core for functionality (it doesn't include news >> entries, or documentation, or any of the other steps that would be >> needed prior to commit). >> >> https://wiki.php.net/rfc/parameter_type_casting_hints >> >> Please provide feedback here on the implementation and RFC topics. >> >> Thanks, >> >> Anthony >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> >