Re: Type hinting
| From: | Stas Malyshev | Date: | Fri, 28 May 2010 17:45:33 +0000 |
| Subject: | Re: Type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48557@lists.php.net to get a copy of this message | ||
Hi!
Which is why, for instance, PHPUnit today is full of code like this
public function foo($flag)
{
if (!is_bool($flag)) {
throw new InvalidArgumentException(/* ... */);
}
}
This is the type of code that I want to get rid off using scalar type
hints.
The question here is does it make sense somewhere outside PHPUnit? I.e. I can see why unit test cares if method returned "false" or "" or 0 - because if you test for value false, you should get false. However, outside the test realm, why would you case if you need to disable an option and get 0 instead of false? Was it unclear what 0 meant? Is there any problem with interpreting what user intended to do and doing it? Why insist on having right zval bits?
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227