Hi!
type hinting for arrays and objects does the same (catchable fatal error on mismatch), whats the difference?
> if you start using a piece of code, which uses type hinting for > non-scalar variables, you already have to deal with this kind of > situation (custom error handler, or catching the exception)
The difference is it is very rare that you pass object of one class instead of another, and it is usually an obvious mistake (like using wrong variable, etc.). It is very frequent that you want number and get "1" instead - almost all incoming data for PHP are strings. So you may get by with basically ignoring class types since you'd almost never would have to handle failure in your app. With scalar strict typing, you'd most certainly have to handle failures. Also, it never makes sense to convert one object type into another, and almost never this operation can be defined. On the other hand, scalar types are very frequently converted in PHP and generally considered rather interchangeable in other dynamic languages. Nobody would refuse to understand that IS_INTEGER:0 and IS_BOOL:0 is the same and mean "false". If you make your application have this distinction, you'd have to code for it in a way that never was what PHP is about.
So from my point of view, you are arguing against the type hinting itself, which is too late IMHO.
No it is not too late. It is never too late to stop PHP from turning into Java wannabe. If you want strictly-typed exclusively-OO language, you know where to find them.
-- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php