Re: PEAR.php to PHP5
| From: | Hans Lellelid | Date: | Sat, 19 Jun 2004 15:08:58 +0000 |
| Subject: | Re: PEAR.php to PHP5 | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-30935@lists.php.net to get a copy of this message | ||
Hans Lellelid wrote:
I think a more progressive PHP5 solution would be to add that observer functionality into PEAR_Exception. And have the constructor signal observers. PEAR_Exception::addObserver('name', array($obj, 'methodName')); And then just throw new PEAR_Exception("Msg", ERR_CODE);Attached (if it makes it through) is a simplified version of PEAR_Exception that has the functionlity mentioned. Note that the point of this is not address any compatibility (which I feel is unnecessary given that php4 packages have to be rewritten anyway), but rather to address missing features of Exception. I think Tobias was right (sorry for arguing, Toby); a PEAR_Exception base class could be quite useful -- as it will add missed features from PEAR_Error and play nice w/ non-PEAR code. This version handles nesting in addition to the observers. (Though I simplified & made all observers callbacks.) Hans