php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #53727
Patch fix-is_subclass_of-PHP_5_3.diff revision 2011-06-30 22:33 UTC by ralph at smashlabs dot com
Patch is_subclass_of-ignoring_interfaces revision 2011-01-13 00:06 UTC by marc at easen dot co dot uk

Patch is_subclass_of-ignoring_interfaces for Class/Object related Bug #53727

Patch version 2011-01-13 00:06 UTC

Return to Bug #53727 | Download this patch
Patch Revisions:

Developer: marc@easen.co.uk

Index: ext/standard/tests/class_object/is_subclass_of_variation_002.phpt
===================================================================
--- ext/standard/tests/class_object/is_subclass_of_variation_002.phpt	(revision 306670)
+++ ext/standard/tests/class_object/is_subclass_of_variation_002.phpt	(working copy)
@@ -80,6 +80,15 @@
       var_dump( is_subclass_of($object, $value) );
 };
 
+
+// Bug #53727 - Inconsistent behavior of is_subclass_of with interfaces
+interface MyInterface {}
+class ParentClass implements MyInterface { }
+class ChildClass extends ParentClass { }
+echo "\nBug #53727\n";
+echo (is_subclass_of('ChildClass', 'MyInterface') ? 'true' : 'false') . "\n";
+echo (is_subclass_of('ParentClass', 'MyInterface') ? 'true' : 'false') . "\n";
+
 echo "Done";
 ?>
 --EXPECTF--
@@ -168,4 +177,8 @@
 
 Arg value  
 bool(false)
+
+Bug #53727
+false
+false
 Done
\ No newline at end of file
Index: Zend/zend_builtin_functions.c
===================================================================
--- Zend/zend_builtin_functions.c	(revision 306670)
+++ Zend/zend_builtin_functions.c	(working copy)
@@ -855,6 +855,9 @@
 		retval = 0;
 	} else {
 		if (only_subclass) {
+			if ((*ce)->ce_flags & ZEND_ACC_INTERFACE) {
+				RETURN_FALSE;
+			}
 			if (!instance_ce) {
 				instance_ce = Z_OBJCE_P(obj)->parent;
 			} else {
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 09:02:28 2014 UTC