Re: PEAR.php to PHP5
| From: | Hans_L | Date: | Thu, 01 Jul 2004 18:54:22 +0000 |
| Subject: | Re: PEAR.php to PHP5 | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-31469@lists.php.net to get a copy of this message | ||
Welcome back, Greg.
Stirring up some old ghosts, I see :)
Greg Beaver wrote:
This code is nice - and once php4 is completely forgotten, it would handle the issues PEAR_ErrorStack seeks to solve wonderfully.PEAR_ErrorStack is a great package, but I see it as simply a different way of handling errors (I know that you can use it to throw Exceptions also, but not sure I see the advantage to doing Exceptions that way). I see a stack system as useful in certain cases -- particularly for warnings instead of actual errors -- but for PHP5 classes I like to use PHP's built-in error handling. It works awesome for *error*-handling; warnings and notices leave some room for interpretation. Personally, I'm a big fan of trigger_error for everything that need not be handled.
the package attribute could be handled simply by instanceof and extension. sub-packaging could be handled by extension hierarchies. Adding context generation (NOT handled in your example) and error message generation from context information (NOT handled - getMessage() is a final method, and can't be overridden) would be trivial. However, until PHP4 is extinct, the package is more of a curiosity.What do you mean by context generation? I think that (and have been meaning to provide diff) PEAR_Exception needs stack trace to show up in __toString() method, but this is a minor thing. Also, while getMessage() may be final there's nothing stopping you from changing the protected $message property. I do that on several exception subclasses I use. I want to use this package in Net_GeoIP as soon as it's considered "feature-complete". I don't see it as a curiosity at all. It adds some nice features to exceptions without inventing a new error handling scheme. I'm going to soon be releasing an alpha version of Net_GeoIP; if PEAR_Exception were ready (and available in PHP distrib) I'd use it today.
(*) A PHP5-system does not use ANY legacy code. a package that relied upon Tomas's error handling system would simply not work with PEAR_ErrorStack, or any other PHP4-compatible code.Yup; that's true. I, for example, am building for E_STRICT & that does mean no legacy PEAR libs. I love PEAR_Exception because it's small, lightweight, adds features (observers especially), and uses PHP5's error model so it will be universally applicable. Hans