Re: getThis and static methods

From: Date: Fri, 01 Feb 2008 09:09:05 +0000
Subject: Re: getThis and static methods
References: 1 2 3 4  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-5102@lists.php.net to get a copy of this message
On Fri, 1 Feb 2008 08:23:11 +0100 Anatoliy Belsky <thinker@rubay.de> wrote: Hi! > may be should something like this work whithin A::foo(): > > zval *obj = getThis(); > if(obj) { > zend_class_entry *ce = Z_OBJCE_P(obj); > > if(ce && 0 == strcmp("A", (*ce)->name)) { > php_printf("foo called from the A object instance context"); > } > } > > > > in php >= 5.3 may also EG(called_scope) be working, which allways contains the > name of the calling context I used to get ce->parent ( and loops ) to fetch parent and base class. But I found it unstable for extension which should work for PHP4 and PHP5 ( * vs ** ). Yes, PHP4 is history now, but I would like to avoid troubles when PHP6 will be released. I thought there's something like zend_class_get_base_class(Z_OBJCE_P(getThis())); or zend_class_get_base_class_by_name(const char *classname);. Piotras

« previous php.pecl.dev (#5102) next »