Re: Detect zval instance of class/subclass

From: Date: Thu, 23 Sep 2010 10:45:45 +0000
Subject: Re: Detect zval instance of class/subclass
References: 1 2  Groups: php.pecl.dev php.pecl.dev 
Request: Send a blank email to pecl-dev+get-7680@lists.php.net to get a copy of this message
On 23/09/10 11:38, Johannes Schlüter wrote:
Hi On Wed, 2010-09-22 at 19:35 +0100, Mark Skilbeck wrote:
Hi, all. I was wondering - supposing a function takes a parameter that can be either TypeA or TypeB, or any subclass thereof, what is the best way to check for this requirement? Initially I was just comparing the names in the class entry, but, of course, that won't work for subclassed objects.
See README.PARAMETER_PARSING_API from the php-src: [...] O - object of specific type given by class entry (zval*, zend_class_entry) [...] /* Gets an object of class specified by my_ce, and an optional double. */ zval *obj; double d = 0.5; zend_class_entry *my_ce; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|d",
                           &obj, my_ce,&d) == FAILURE) {
     return;
} johannes
Thanks. Johannes. Although the problem was with allowing an object that could be an instance of *two* different classes. I used the instanceof_function against the two class entries, so that I could include any extending classes also. -- Mark Skilbeck mahcuz.com | gtk.php.net | pecl.php.net/cairo | docs.php.net

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