felipe Wed Jan 30 10:54:41 2008 UTC
Modified files:
/php-src/ext/reflection php_reflection.c
/php-src/ext/reflection/tests bug43926.phpt
Log:
Fixed Bug #43926 (isInstance() isn't equivalent to instanceof operator)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.290&r2=1.291&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.290
php-src/ext/reflection/php_reflection.c:1.291
--- php-src/ext/reflection/php_reflection.c:1.290 Wed Jan 16 14:19:07 2008
+++ php-src/ext/reflection/php_reflection.c Wed Jan 30 10:54:41 2008
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.290 2008/01/16 14:19:07 helly Exp $ */
+/* $Id: php_reflection.c,v 1.291 2008/01/30 10:54:41 felipe Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -3481,7 +3481,7 @@
return;
}
GET_REFLECTION_OBJECT_PTR(ce);
- RETURN_BOOL(ce == Z_OBJCE_P(object));
+ RETURN_BOOL(HAS_CLASS_ENTRY(*object) &&
instanceof_function(Z_OBJCE_P(object), ce));
}
/* }}} */
@@ -5032,7 +5032,7 @@
php_info_print_table_start();
php_info_print_table_header(2, "Reflection", "enabled");
- php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.290
2008/01/16 14:19:07 helly Exp $");
+ php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.291
2008/01/30 10:54:41 felipe Exp $");
php_info_print_table_end();
} /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/bug43926.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/reflection/tests/bug43926.phpt
diff -u /dev/null php-src/ext/reflection/tests/bug43926.phpt:1.2
--- /dev/null Wed Jan 30 10:54:41 2008
+++ php-src/ext/reflection/tests/bug43926.phpt Wed Jan 30 10:54:41 2008
@@ -0,0 +1,37 @@
+--TEST--
+Bug#43926 - isInstance() isn't equivalent to instanceof operator
+--FILE--
+<?php
+
+class E {
+}
+class D extends E {
+}
+
+class A extends D {
+}
+
+class C extends A {
+}
+
+$ra = new ReflectionClass('A');
+$rc = new ReflectionClass('C');
+$rd = new ReflectionClass('D');
+$re = new ReflectionClass('E');
+
+$ca = $ra->newInstance();
+$cc = $rc->newInstance();
+$cd = $rd->newInstance();
+$ce = $re->newInstance();
+
+print("Is? A ". ($ra->isInstance($ca) ? 'true' : 'false') .", instanceof: ".
(($ca instanceof A) ? 'true' : 'false') ."\n");
+print("Is? C ". ($ra->isInstance($cc) ? 'true' : 'false') .", instanceof: ".
(($ca instanceof C) ? 'true' : 'false') ."\n");
+print("Is? D ". ($ra->isInstance($cd) ? 'true' : 'false') .", instanceof: ".
(($ca instanceof D) ? 'true' : 'false') ."\n");
+print("Is? E ". ($ra->isInstance($ce) ? 'true' : 'false') .", instanceof: ".
(($ca instanceof E) ? 'true' : 'false') ."\n");
+
+?>
+--EXPECT--
+Is? A true, instanceof: true
+Is? C false, instanceof: false
+Is? D true, instanceof: true
+Is? E true, instanceof: true
\ No newline at end of file
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php