[php] Provide zend_class_implements_interface() for 7.x
It seems instanceof_function_ex() isn't a viable option for PHP 7.3 and earlier - the implementation is strangely wrong. So let's just provide a compatibility implementation which does what zend_class_implements_interface() does in 8.x and use that for all 7.x so there are fewer variants to worry about testing.
This commit is contained in:
parent
91470ca62d
commit
4f5dfd596d
1 changed files with 18 additions and 6 deletions
|
|
@ -96,12 +96,24 @@ static int default_error_code = E_ERROR;
|
||||||
static zend_class_entry SWIG_Php_swig_wrapped_interface_ce;
|
static zend_class_entry SWIG_Php_swig_wrapped_interface_ce;
|
||||||
|
|
||||||
#if PHP_MAJOR_VERSION == 7
|
#if PHP_MAJOR_VERSION == 7
|
||||||
/* The sense of parameter 3 of instanceof_function_ex() changed in PHP 7.4! */
|
/* zend_class_implements_interface() was new in PHP 8.0.
|
||||||
# if PHP_MINOR_VERSION <= 3
|
*
|
||||||
# define zend_class_implements_interface(C, I) instanceof_function_ex(C, I, 0)
|
* We could use instanceof_function_ex(C, I, 1) here for 7.4, but for 7.3
|
||||||
# else
|
* and earlier that doesn't work, so instead we just provide a compatibility
|
||||||
# define zend_class_implements_interface(C, I) instanceof_function_ex(C, I, 1)
|
* implementation which does what zend_class_implements_interface() does in 8.x
|
||||||
# endif
|
* and use that for all 7.x so there are fewer variants to worry about testing.
|
||||||
|
*/
|
||||||
|
static int zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce) {
|
||||||
|
uint32_t i;
|
||||||
|
if (class_ce->num_interfaces) {
|
||||||
|
for (i = 0; i < class_ce->num_interfaces; i++) {
|
||||||
|
if (class_ce->interfaces[i] == interface_ce) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* used to wrap returned objects in so we know whether they are newobject
|
/* used to wrap returned objects in so we know whether they are newobject
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue