What I mean is that you can catch recoverable fatal error in your error handler and at least be notified of what happened. Yes, you cannot go back in your script to corrent anything after that but you can show a detailed error message and send error email to developer.
Just the same thing you can do when you hint class name for your input parameter - it will generate catchable fatal error if object is not an instance of expected class. Dmitri Snytkine Web Developer Ultra Logistics, Inc. Phone: (888) 220-4640 x 2097 Fax: (888) 795-6642 E-Mail: dsnytk...@ultralogistics.com Web: www.ultralogistics.com "A Top 100 Logistics I.T. Provider in 2011" -----Original Message----- From: Stas Malyshev [mailto:smalys...@sugarcrm.com] Sent: Thursday, December 22, 2011 2:19 PM To: Dmitri Snytkine Cc: 'Sebastian Bergmann'; internals@lists.php.net Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC Hi! > is_numeric is not good enough in some cases, like when searching for value > in MongoDB where it matches agains typed value. > > function age_check(int $age) > { > // do stuff > } > > This would require less code, easier to read and will catch wrong type at > runtime easy and throw recoverable fatal error that you can catch. You can catch and do what? By that time you application has failed with no chance to recover, since you can't go back to age_check call and say "oh, sorry, when I said '1' I actually meant integer 1, please accept it!" The only thing you can do is to output a nice error message, and since this is nothing the user can correct, since it's not his problem but a code bug, it'll be something like "something went wrong, oops, please go to another page of the site and hope it will be programmed better than this one!". That's pretty much your options when using strict typed function - unless you either have strict typing throughout the whole code path(s) that lead to the age_check call or do an explicit check with explicit failure handling each time you try to call it. > the well designed IDE can also catch error in your code if your parameters > and all returnes are typed, so that will also save you a lot of time. I start to feel "well designed IDE" is a substitute for a compiler for some. PHP is not a compiled language, however, at least not yet - and since it's not, relying on mythical "well designed IDE" to perform the function that compiler performs in static-typed compiled languages is, IMHO, misguided. -- 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 -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php