Re: [Zend Engine 2] Type hints revisited [IllegalArgumentException instead of E_ERROR]
| From: | Timm Friebe | Date: | Fri, 28 Mar 2003 17:15:27 +0000 |
| Subject: | Re: [Zend Engine 2] Type hints revisited [IllegalArgumentException instead of E_ERROR] | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-439@lists.php.net to get a copy of this message | ||
On Thu, 2003-03-27 at 17:16, Timm Friebe wrote:
> I've implemented an additional feature for type hints that will throw an
> exception instead of bailing out in case an incorrect type is passed.
[...LONG disussion...]
After reading through a bunch of mails this generated, I get the idea
that most people here would be happier with an E_WARNING and the
function not being executed.
That gives:
- the OOP purist the possibility to throw an exception (in a userland
error handler)
- the SOAP server a way to nicely recover
- the API designer a way to tell the user (s)he's messed up
- the "standard" programmer what (s)he's used to (PHP is quite
forgiving in the way it handles incorrect argument types and
usually warns about this)
Attached is the E_WARNING variant, an example script and its output.
- Timm
Attachment: [text/x-patch] zend_hints_warning.diff
Attachment: [application/x-php] hints.php
Warning: Argument 1 must be an instance of date in /usr/home/thekid/devel/php/hints.php on line 42 object(article)#1 (3) { ["created_at"]=> object(date)#2 (1) { [""]=> int(1048871463) } ["lastchange"]=> NULL ["revisions"]=> array(0) { } } string(31) "Fri, 28 Mar 2003 18:11:03 +0100" Warning: Argument 3 must be an instance of date in /usr/home/thekid/devel/php/hints.php on line 25 NULL
Attachment: [text/x-patch] zend_hints_warning.diff
Attachment: [application/x-php] hints.php
Warning: Argument 1 must be an instance of date in /usr/home/thekid/devel/php/hints.php on line 42 object(article)#1 (3) { ["created_at"]=> object(date)#2 (1) { [""]=> int(1048871463) } ["lastchange"]=> NULL ["revisions"]=> array(0) { } } string(31) "Fri, 28 Mar 2003 18:11:03 +0100" Warning: Argument 3 must be an instance of date in /usr/home/thekid/devel/php/hints.php on line 25 NULL