At 13:59 27/05/2010, Ilia Alshanetsky wrote:
Zeev,
Auto-conversion does not validate input to the function/method, it
merely obfuscates the "wrong" input by converting it to desired type
resulting in a potentially un-expected value. I must say I am
completely against the auto-conversion hint idea.
All of PHP is built on that kind of conversion. See Brian Moon's
email for a detailed instructions.
BTW - even if strict type checking was implemented, do you truly
think people won't simply cast their inputs to make PHP shutup about
"42" not being a valid int? Let me assure you, they would. You'd
gain nothing - as a matter of fact you'd lose out a bit since "abc"
strings or arrays will happily cast into (int), while with our
proposed solution - they won't.
As far as your example goes consider a function that expects a
boolean, but instead gets an int/string/float, which in nearly all
cases will result in TRUE. Which is not the desired outcome.
Again, I don't think you can hope for anybody doing anything but
(bool) cast before calling the function. And anyway, how is that
different from if ($foo)? or while($bar)? Why would functions
arguments behave any differently?
If you care explicitly about zval.type being boolean, use is_bool().
Zeev
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php