Re: type hinting
| From: | Stefan Priebsch | Date: | Mon, 07 Jan 2008 14:19:57 +0000 |
| Subject: | Re: type hinting | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-34583@lists.php.net to get a copy of this message | ||
Sam Barrow schrieb:
Well these errors can be handled like any other, as long as they don't issue a fatal.That's exactly my point. You need to handle them. So in pidgin PHP that could look something like function foo(int $foo) {} try { foo($bar); } catch (WhateverException $e) { since $bar cannot be converted to int, do_whatever } Is that really betten than writing if (!is_int($bar)) do_whatever foo($bar) or function foo($foo) { if (!is_int($foo)) do_whatever } My point is: aside from the "academic purity" of more strictness, what is the real benefit in this scenario? Any defensive coder will always write explicit type checks to prevent runtime errors. Regards, Stefan -- >e-novative> - We make IT work for you. e-novative GmbH - HR: Amtsgericht München HRB 139407 Sitz: Wolfratshausen - GF: Dipl. Inform. Stefan Priebsch http://www.e-novative.de - GnuPG Key: 0x7DB67F7F