|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patch Is_a_with_allow_string_argument_v2 for Scripting Engine problem Bug #55475Patch version 2011-09-22 23:26 UTC Return to Bug #55475 | Download this patchThis patch renders other patches obsolete Obsolete patches: Patch Revisions:Developer: alan_k@php.net
Index: Zend/zend_builtin_functions.c
===================================================================
--- Zend/zend_builtin_functions.c (revision 317068)
+++ Zend/zend_builtin_functions.c (working copy)
@@ -839,13 +839,14 @@
int class_name_len;
zend_class_entry *instance_ce;
zend_class_entry **ce;
+ zend_bool allow_string = only_subclass ? 1 : 0;
zend_bool retval;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &obj, &class_name, &class_name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|b", &obj, &class_name, &class_name_len, &allow_string) == FAILURE) {
return;
}
-
- if (Z_TYPE_P(obj) == IS_STRING) {
+
+ if (allow_string && 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;
@@ -871,7 +872,8 @@
}
-/* {{{ proto bool is_subclass_of(object object, string class_name)
+
+/* {{{ proto bool is_subclass_of(mixed object_or_string, string class_name [, boolean allow_string=true])
Returns true if the object has this class as one of its parents */
ZEND_FUNCTION(is_subclass_of)
{
@@ -880,13 +882,12 @@
/* }}} */
-/* {{{ 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_or_string, string class_name [, boolean allow_string=false])
+ Returns true if the first argument 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);
}
-/* }}} */
/* {{{ add_class_vars */
|
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 03:00:02 2025 UTC |