Re: RE: Optional scalar type hinting
| From: | Sam Barrow | Date: | Fri, 04 Jan 2008 00:31:11 +0000 |
| Subject: | Re: RE: Optional scalar type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34379@lists.php.net to get a copy of this message | ||
If foo() is changed, the type hints should be removed. Most of the time
however, a function will not change its functionality enough to change
the purpose of the arguments.
On Thu, 2008-01-03 at 14:50 -0800, Stanislav Malyshev wrote:
> > type-hinting is asserting.
> > checking of types is needed only on interface-border points (where
>
> With strict checking, that means instead of calling:
> foo($bar);
> you'd have now to do:
> if(is_integer($bar)) {
> // stupid foo() call would blow up if passed not integer, so I have
> to manually handle it
> // oh wait, actually I don't have any way to handle it - I need
> foo() to be called to proceed
> // so let's just
> die("can't call foo() because \$bar is not integer");
> }
> foo($bar);
>
> Now how it's easier or makes application more stable? What happens if
> foo() is changed and now accepts both integers and strings? What happens
> if someone forgets to write a wrapper?
> --
> Stanislav Malyshev, Zend Software Architect
> stas@zend.com http://www.zend.com/
> (408)253-8829 MSN: stas@zend.com
>