Re: PEAR_Warning proof of concept

From: Date: Sat, 10 Jul 2004 14:06:59 +0000
Subject: Re: PEAR_Warning proof of concept
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-31829@lists.php.net to get a copy of this message
Hi Greg, At the same time of you, was thinking/coding in Warnings too, excuse me for that. I took a different approach than you, maybe we can exchange ideas. For me warnings are: 1) Non fatal 2) Non "returnable" 3) Not objects (too big and slow for handling a big ammount of warnings) 4) Easily avaible mechanism (that's why I've put the code in PEAR_Exception) My approach works this way: class Foo { function bar() { [..] PEAR_Exception::addWarning('Oops take care'); [..] } } $foo = new Foo; while ($row = $foo->bar()) { [..] } if ($w = PEAR_Exception::getWarning()) { echo $w['message'] . "!!!!"; } It has another set of features like: - A definable callback function (same features as exception observers) - Stackable warnings - Size control over the stack - Per-context warning adding and retrieving All that in just ~30 lines extra code for PEAR_Exception. I've commited the code to CVS for easily reviewing: http://cvs.php.net/co.php/pear-core/PEAR/Exception.php?&r=1.7 Don't worry I'll remove the code once people comment it. Tomas V.V.Cox Btw: Planning to rename PEAR_Exception to PEAR_Error Greg Beaver wrote:
------------------------------------------------------------------------ <?php require_once 'PEAR/Exception.php'; class PEAR_Warning extends PEAR_Exception { [..]


« previous php.pear.dev (#31829) next »