summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--Zend/tests/bug53727.phpt22
-rwxr-xr-xZend/tests/is_a.phpt2
-rw-r--r--Zend/zend_builtin_functions.c31
-rw-r--r--ext/standard/tests/class_object/is_a_variation_001.phpt8
5 files changed, 41 insertions, 26 deletions
diff --git a/NEWS b/NEWS
index 13a004247a..902a95c74f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,10 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2011, PHP 5.3.7
+- Core
+ . Fixed bug #53727 (Inconsistent behavior of is_subclass_of with interfaces)
+ (Ralph Schindler, Dmitry)
+
- PDO DBlib:
. Fixed bug #54329 (MSSql extension memory leak).
(dotslashpok at gmail dot com)
diff --git a/Zend/tests/bug53727.phpt b/Zend/tests/bug53727.phpt
new file mode 100644
index 0000000000..22cd5232c7
--- /dev/null
+++ b/Zend/tests/bug53727.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #53727 (Inconsistent behavior of is_subclass_of with interfaces)
+--FILE--
+<?php
+interface MyInterface {
+ const TEST_CONSTANT = true;
+}
+
+class ParentClass implements MyInterface { }
+
+class ChildClass extends ParentClass { }
+
+echo (is_subclass_of('ChildClass', 'MyInterface') ? 'true' : 'false') . "\n";
+echo (defined('ChildClass::TEST_CONSTANT') ? 'true' : 'false') . "\n";
+
+echo (is_subclass_of('ParentClass', 'MyInterface') ? 'true' : 'false') . "\n";
+echo (defined('ParentClass::TEST_CONSTANT') ? 'true' : 'false') . "\n";
+--EXPECT--
+true
+true
+true
+true
diff --git a/Zend/tests/is_a.phpt b/Zend/tests/is_a.phpt
index a074194c4d..0a01eb756e 100755
--- a/Zend/tests/is_a.phpt
+++ b/Zend/tests/is_a.phpt
@@ -38,6 +38,6 @@ bool(true)
bool(false)
bool(false)
bool(true)
-bool(false)
+bool(true)
AUTOLOAD 'X1'
bool(false)
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 6888b7f662..d0276091b6 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -822,45 +822,26 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
return;
}
- if (only_subclass && Z_TYPE_P(obj) == IS_STRING) {
+ if (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) {
zend_error(E_WARNING, "Unknown class passed as parameter");
RETURN_FALSE;
}
instance_ce = *the_ce;
- } else if (Z_TYPE_P(obj) != IS_OBJECT) {
- RETURN_FALSE;
+ } else if (Z_TYPE_P(obj) == IS_OBJECT && HAS_CLASS_ENTRY(*obj)) {
+ instance_ce = Z_OBJCE_P(obj);
} else {
- instance_ce = NULL;
- }
-
- /* TBI!! new object handlers */
- if (Z_TYPE_P(obj) == IS_OBJECT && !HAS_CLASS_ENTRY(*obj)) {
RETURN_FALSE;
}
if (zend_lookup_class_ex(class_name, class_name_len, 0, &ce TSRMLS_CC) == FAILURE) {
retval = 0;
} else {
- if (only_subclass) {
- if (!instance_ce) {
- instance_ce = Z_OBJCE_P(obj)->parent;
- } else {
- instance_ce = instance_ce->parent;
- }
- } else {
- instance_ce = Z_OBJCE_P(obj);
- }
-
- if (!instance_ce) {
- RETURN_FALSE;
- }
-
- if (instanceof_function(instance_ce, *ce TSRMLS_CC)) {
- retval = 1;
- } else {
+ if (only_subclass && instance_ce == *ce) {
retval = 0;
+ } else {
+ retval = instanceof_function(instance_ce, *ce TSRMLS_CC);
}
}
diff --git a/ext/standard/tests/class_object/is_a_variation_001.phpt b/ext/standard/tests/class_object/is_a_variation_001.phpt
index d2d6ce2407..1021544065 100644
--- a/ext/standard/tests/class_object/is_a_variation_001.phpt
+++ b/ext/standard/tests/class_object/is_a_variation_001.phpt
@@ -144,15 +144,23 @@ Arg value
bool(false)
Arg value
+
+Warning: Unknown class passed as parameter in %sis_a_variation_001.php on line %d
bool(false)
Arg value
+
+Warning: Unknown class passed as parameter in %sis_a_variation_001.php on line %d
bool(false)
Arg value string
+
+Warning: Unknown class passed as parameter in %sis_a_variation_001.php on line %d
bool(false)
Arg value String
+
+Warning: Unknown class passed as parameter in %sis_a_variation_001.php on line %d
bool(false)
Arg value