]> granicus.if.org Git - php/commitdiff
Fixed bug #70528 (assert() with instanceof adds apostrophes around class name)
authorXinchen Hui <laruence@gmail.com>
Sun, 20 Sep 2015 02:49:36 +0000 (19:49 -0700)
committerXinchen Hui <laruence@gmail.com>
Sun, 20 Sep 2015 02:49:36 +0000 (19:49 -0700)
NEWS
Zend/tests/assert/bug70528.phpt [new file with mode: 0644]
Zend/zend_ast.c

diff --git a/NEWS b/NEWS
index ac0d0506efe9de9064dfd0e2c56dc4137a1a17bd..eeeadbcfd9615d6ae65db6999a7fa07ab0e562e8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 01 Oct 2015, PHP 7.0.0 RC 4
 
 - Core:
+  . Fixed bug #70528 (assert() with instanceof adds apostrophes around class
+    name). (Laruence)
   . Fixed bug #70481 (Memory leak in auto_global_copy_ctor() in ZTS build).
     (Laruence)
 
diff --git a/Zend/tests/assert/bug70528.phpt b/Zend/tests/assert/bug70528.phpt
new file mode 100644 (file)
index 0000000..1b58038
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Bug #70528 (assert() with instanceof adds apostrophes around class name)
+--INI--
+zend.assertions=1
+assert.exception=0
+assert.warning=1
+--FILE--
+<?php
+
+namespace Foo;
+class Bar {}
+
+$bar = "Bar";
+assert(new \stdClass instanceof $bar);
+assert(new \stdClass instanceof Bar);
+assert(new \stdClass instanceof \Foo\Bar);
+?>
+--EXPECTF--
+Warning: assert(): assert(new \stdClass() instanceof $bar) failed in %sbug70528.php on line %d
+
+Warning: assert(): assert(new \stdClass() instanceof Bar) failed in %sbug70528.php on line %d
+
+Warning: assert(): assert(new \stdClass() instanceof \Foo\Bar) failed in %sbug70528.php on line %d
index d36ce0b2ad5bdc91eacf4e0718fd4cebb94950a1..9dadd35d6a39ed36158e877ad1c40eee549652c4 100644 (file)
@@ -1349,7 +1349,11 @@ simple_list:
                        zend_ast_export_ex(str, ast->child[1], 0, indent);
                        smart_str_appendc(str, ')');
                        break;
-               case ZEND_AST_INSTANCEOF: BINARY_OP(" instanceof ", 230, 231, 231);
+               case ZEND_AST_INSTANCEOF:
+                       zend_ast_export_ex(str, ast->child[0], 0, indent);
+                       smart_str_appends(str, " instanceof ");
+                       zend_ast_export_ns_name(str, ast->child[1], 0, indent);
+                       break;
                case ZEND_AST_YIELD:
                        if (priority > 70) smart_str_appendc(str, '(');
                        smart_str_appends(str, "yield ");