php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch is_class_of.diff for Scripting Engine problem Bug #55475Patch version 2011-09-20 21:32 UTC Return to Bug #55475 | Download this patchThis patch renders other patches obsolete Obsolete patches: Patch Revisions:Developer: alan_k@php.netIndex: Zend/zend_builtin_functions.c =================================================================== --- Zend/zend_builtin_functions.c (revision 317068) +++ Zend/zend_builtin_functions.c (working copy) @@ -62,6 +62,7 @@ #endif static ZEND_FUNCTION(get_included_files); static ZEND_FUNCTION(is_subclass_of); +static ZEND_FUNCTION(is_class_of); static ZEND_FUNCTION(is_a); static ZEND_FUNCTION(get_class_vars); static ZEND_FUNCTION(get_object_vars); @@ -145,6 +146,11 @@ ZEND_ARG_INFO(0, class_name) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_is_class_of, 0, 0, 2) + ZEND_ARG_INFO(0, object) + ZEND_ARG_INFO(0, class_name) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_get_class_vars, 0, 0, 1) ZEND_ARG_INFO(0, class_name) ZEND_END_ARG_INFO() @@ -273,6 +279,7 @@ ZEND_FE(get_included_files, arginfo_zend__void) ZEND_FALIAS(get_required_files, get_included_files, arginfo_zend__void) ZEND_FE(is_subclass_of, arginfo_is_subclass_of) + ZEND_FE(is_class_of, arginfo_is_class_of) ZEND_FE(is_a, arginfo_is_subclass_of) ZEND_FE(get_class_vars, arginfo_get_class_vars) ZEND_FE(get_object_vars, arginfo_get_object_vars) @@ -832,7 +839,7 @@ /* }}} */ -static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) +static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool use_autoload) { zval *obj; char *class_name; @@ -845,7 +852,7 @@ return; } - if (Z_TYPE_P(obj) == IS_STRING) { + if (use_autoload && Z_TYPE_P(obj) == IS_STRING) { zend_class_entry **the_ce; if (zend_lookup_class(Z_STRVAL_P(obj), Z_STRLEN_P(obj), &the_ce TSRMLS_CC) == FAILURE) { RETURN_FALSE; @@ -860,7 +867,7 @@ if (zend_lookup_class_ex(class_name, class_name_len, NULL, 0, &ce TSRMLS_CC) == FAILURE) { retval = 0; } else { - if (only_subclass && instance_ce == *ce) { + if (use_autoload == 2 && instance_ce == *ce) { retval = 0; } else { retval = instanceof_function(instance_ce, *ce TSRMLS_CC); @@ -871,17 +878,26 @@ } -/* {{{ proto bool is_subclass_of(object object, string class_name) +/* {{{ proto bool is_subclass_of(mixed object_or_string, string class_name) Returns true if the object has this class as one of its parents */ ZEND_FUNCTION(is_subclass_of) { + is_a_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2); +} +/* }}} */ + + +/* {{{ proto bool is_class_of(mixed object_or_string, string class_name) + Returns true if the object is of this class or has this class as one of its parents */ +ZEND_FUNCTION(is_class_of) +{ is_a_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); } /* }}} */ -/* {{{ proto bool is_a(object object, string class_name) - Returns true if the object is of this class or has this class as one of its parents */ +/* {{{ proto bool is_a(mixed object, string class_name) + Returns true if the object is an object and is this class or has this class as one of its parents */ ZEND_FUNCTION(is_a) { is_a_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Thu Nov 21 18:01:29 2024 UTC |