On Thu, Apr 17, 2008 at 9:33 AM, Stanislav Malyshev <[EMAIL PROTECTED]> wrote:
> Just for the record, I see absolutely no sense in strict type hints. While > there might be some use cases when you want to save typing by having > function convert the arguments instead of you doing it manually - there's > absolutely no sense to check types strictly in PHP, especially taking into > attention that no API ever worked that way, and that it would force users to > surround each call to such function with checks for argument types, since > PHP can not have static type control. Using such feature would be a > nightmare. You have a good point, but I think it might have slightly more benefit then we may think. Less code bloat for the checks many of us already enforce is one. Doing some greps in the Zend Framework is a good example. grep -riE -A2 "is_(binary|bool|double|float|int|long|null|numeric|object|real|resource|scalar|string|unicode)" * I get tons of parameter checks which throw exceptions, so users already have to check there code prior to sending it up the chain. And by "Check" a good framework, like Zend, will do the boundary checking for you, so as long as it is the right type you are ok. So: function foo($var) { if(!is_int($var)) { throw new exception('not int'); }} Turns to: function foo(int $bar) { } which is called like this in both cases, maybe with a try catch etc etc: foo((int) $baz['bar']); -Chris