com php-src: Fixed bug #70528 (assert() with instanceof adds apostrophes around class name): NEWS Zend/tests/assert/bug70528.phpt Zend/zend_ast.c
| From: | Xinchen Hui | Date: | Sun, 20 Sep 2015 02:49:36 +0000 |
| Subject: | com php-src: Fixed bug #70528 (assert() with instanceof adds apostrophes around class name): NEWS Zend/tests/assert/bug70528.phpt Zend/zend_ast.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89085@lists.php.net to get a copy of this message | ||
Commit: bb07905a4a34e3e7d6f1ebe94818dd88ba951dcb
Author: Xinchen Hui <laruence@gmail.com> Sat, 19 Sep 2015 19:49:36 -0700
Parents: 509712c7d9056b4ceb50134bfeea1a1115720744
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bb07905a4a34e3e7d6f1ebe94818dd88ba951dcb
Log:
Fixed bug #70528 (assert() with instanceof adds apostrophes around class name)
Bugs:
https://bugs.php.net/70528
Changed paths:
M NEWS
A Zend/tests/assert/bug70528.phpt
M Zend/zend_ast.c
Diff:
diff --git a/NEWS b/NEWS
index ac0d050..eeeadbc 100644
--- 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
index 0000000..1b58038
--- /dev/null
+++ b/Zend/tests/assert/bug70528.phpt
@@ -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
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index d36ce0b..9dadd35 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -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 ");