Re: RE: Optional scalar type hinting

From: Date: Thu, 03 Jan 2008 23:46:42 +0000
Subject: Re: RE: Optional scalar type hinting
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-34372@lists.php.net to get a copy of this message
On Jan 4, 2008 12:23 AM, Stanislav Malyshev <stas@zend.com> wrote: > > This code is just a good argument *FOR* type hints. When foo is: > > function foo(int $bar) {...} > > and you want the code to die if $bar is not integer, then foo($bar) would be > > Why would you want it? I wouldn't want my code to die, I would want it > to work. > > > you have either an int or string representing an integer in $bar, then > > foo((integer)$bar) would work just well. > > And then how exactly strict typing helps you? You can not control at > development time if everybody uses (integer) or not, since being > interpreted PHP has no static type checking. So only option to find it > out is to leave a minefield behind hoping that testers and not actual > users would be ones who make it blow up. What if testers fail to find it? Check google for all fatal errors we introduced about OO strictness (or getter/setter) and you will see what does that mean to be unclear about how strict one should be. I'm not arguing to force strictness but I would love to have it, on a per class basis for example (</dream>). -- Pierre http://blog.thepimp.net | http://www.libgd.org

« previous php.internals (#34372) next »