Re: Re: is_a() calls in PEAR.php
| From: | Alan Knowles | Date: | Fri, 07 May 2004 11:03:15 +0000 |
| Subject: | Re: Re: is_a() calls in PEAR.php | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-28946@lists.php.net to get a copy of this message | ||
as PHP has very strange behaviour when calling static methods it's the only half reliable way of checking for static methods.
class a {
function b () {
c::test();
}
}
class c {
function test() {
echo get_class($this);} } $a = new a; $a->b(); will print (amazingly) 'a' The history of this goes back to the fact that static methods (and the :: syntax was introduced originally so that parent:: worked. ) The general consensus is that this behavior may go away some day.. - but AFAIK it still happens in PHP5, if you look at the zend engine, it adds a bit of an overhead to try and fix this. Regards alan David Grant wrote:
Michael Wallner wrote:-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.comHi Thorsten Suckow-Homberg, you wrote: [...] You may have misunderstood my question, Thorsten. I didn't ask "what is_a() does", but what intention these calls have in the PEAR class. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ So, once again: Why does PEAR check for (isset($this) && is_a($this, 'PEAR')? What should it else be than "a PEAR"? Regards,It seems to be me that it's just a test to see if it's being called statically. However, if the PEAR class was extended, $this would be the name of the extension class. Regards, David