Re: [RFC/PATCH]: push/popErrorHandling() in a class

From: Date: Mon, 01 Mar 2004 10:21:48 +0000
Subject: Re: [RFC/PATCH]: push/popErrorHandling() in a class
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25984@lists.php.net to get a copy of this message
Hi! First of all, I'm new to this list. Greg Beaver told me to join this list and post my suggestions here. I really had some trouble due to the fact that PEAR::setErrorHandling() and PEAR::pushErrorHandling() use isset($this) to find out if the methods are called staticly. > I've attached my testcase, and a patch which fixes the problem for me. It > won't call $this->push/popErrorHandling() unless the class extends PEAR. This enhancement, which is part of PEAR 1.3, works for some cases but isn't safe too. See my example I posted at http://pear.php.net/bugs/bug.php?id=744&thanks=3 So what you really need is a safe way to decide if a method is called staticly or not. For PHP versions >= 4.3 I suggested a workaround: if (function_exists("debug_backtrace") { $call = reset(debug_backtrace()); } else { // assume non static call for PHP < 4.3 $call = array('type' => "->"); } // safe check for PHP >= 4.3 and sometimes working for PHP < 4.3 if (isset($this) && is_a($this, 'PEAR') && $call['type'] == "->") { // non static call } else { // static } Comments about this workaround are welcome. Regards, Markus Kalkbrenner

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