com php-src: Fix nullable type pretty-printing: Zend/tests/asse rt/expect_015.phpt Zend/zend_ast.c
| From: | Nikita Popov | Date: | Fri, 29 Jun 2018 21:22:41 +0000 |
| Subject: | com php-src: Fix nullable type pretty-printing: Zend/tests/asse rt/expect_015.phpt Zend/zend_ast.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102332@lists.php.net to get a copy of this message | ||
Commit: 962706d16c29ec6dd5ec3a78edae9e8907bca20a
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 29 Jun 2018 23:22:41 +0200
Parents: fb09f1341f9924cb3d3a1c12caded82097378063
Branches: PHP-7.1 PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=962706d16c29ec6dd5ec3a78edae9e8907bca20a
Log:
Fix nullable type pretty-printing
Changed paths:
M Zend/tests/assert/expect_015.phpt
M Zend/zend_ast.c
Diff:
diff --git a/Zend/tests/assert/expect_015.phpt b/Zend/tests/assert/expect_015.phpt
index 0c53c75..1679640 100644
--- a/Zend/tests/assert/expect_015.phpt
+++ b/Zend/tests/assert/expect_015.phpt
@@ -20,7 +20,7 @@ assert(0 && ($a = function () {
yield from $x;
}));
-assert(0 && ($a = function &(array &$a, X $b = null) use ($c,&$d) : X {
+assert(0 && ($a = function &(array &$a, ?X $b = null) use ($c,&$d) : ?X {
abstract class A extends B implements C, D {
const X = 12;
const Y = self::X, Z = "aaa";
@@ -161,7 +161,7 @@ Warning: assert(): assert(0 && ($a = function () {
yield from $x;
})) failed in %sexpect_015.php on line %d
-Warning: assert(): assert(0 && ($a = function &(array &$a, X $b = null) use($c,
&$d): X {
+Warning: assert(): assert(0 && ($a = function &(array &$a, ?X $b = null) use($c,
&$d): ?X {
abstract class A extends B implements C, D {
const X = 12;
const Y = self::X, Z = 'aaa';
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c
index fd3cce8..faa3b80 100644
--- a/Zend/zend_ast.c
+++ b/Zend/zend_ast.c
@@ -1080,6 +1080,9 @@ tail_call:
zend_ast_export_ex(str, decl->child[1], 0, indent);
if (decl->child[3]) {
smart_str_appends(str, ": ");
+ if (decl->child[3]->attr & ZEND_TYPE_NULLABLE) {
+ smart_str_appendc(str, '?');
+ }
zend_ast_export_ns_name(str, decl->child[3], 0, indent);
}
if (decl->child[2]) {
@@ -1614,6 +1617,9 @@ simple_list:
break;
case ZEND_AST_PARAM:
if (ast->child[0]) {
+ if (ast->child[0]->attr & ZEND_TYPE_NULLABLE) {
+ smart_str_appendc(str, '?');
+ }
zend_ast_export_ns_name(str, ast->child[0], 0, indent);
smart_str_appendc(str, ' ');
}