From a34699a9ee494af76147a0836e35e5bf5c7cbd14 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 25 Nov 2016 07:14:34 +0100 Subject: php-ast: fix License + add upstream patch for 7.1 --- php-ast-upstream.patch | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 php-ast-upstream.patch (limited to 'php-ast-upstream.patch') diff --git a/php-ast-upstream.patch b/php-ast-upstream.patch new file mode 100644 index 0000000..264e630 --- /dev/null +++ b/php-ast-upstream.patch @@ -0,0 +1,97 @@ +From 81e2938b02ffb734bb85ef2a0fbc74f87b4ba377 Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Thu, 24 Nov 2016 21:49:21 +0100 +Subject: [PATCH] Fix issue #36 + +The emulation of PHP 7.0 list() structure did not account for +skipped elements. +--- + ast.c | 4 ++-- + tests/array_destructuring_old.phpt | 19 +++++++++++++++++++ + 2 files changed, 21 insertions(+), 2 deletions(-) + +diff --git a/ast.c b/ast.c +index ad24ce8..755af14 100644 +--- a/ast.c ++++ b/ast.c +@@ -241,7 +241,7 @@ static inline zend_bool ast_array_is_list(zend_ast *ast) { + } + + for (i = 0; i < list->children; i++) { +- if (list->child[i]->child[1] != NULL || list->child[i]->attr) { ++ if (list->child[i] && (list->child[i]->child[1] != NULL || list->child[i]->attr)) { + return 0; + } + } +@@ -400,7 +400,7 @@ static void ast_fill_children_ht(HashTable *ht, zend_ast *ast, zend_long version + /* Skip docComment child -- It's handled separately */ + continue; + #if PHP_VERSION_ID >= 70100 +- } else if (ast->kind == ZEND_AST_LIST) { ++ } else if (ast->kind == ZEND_AST_LIST && child != NULL) { + /* Emulate simple variable list */ + ast_to_zval(&child_zv, child->child[0], version); + #else +diff --git a/tests/array_destructuring_old.phpt b/tests/array_destructuring_old.phpt +index 6699a80..0aa378d 100644 +--- a/tests/array_destructuring_old.phpt ++++ b/tests/array_destructuring_old.phpt +@@ -8,6 +8,7 @@ require __DIR__ . '/../util.php'; + $code = <<<'PHP' + +Date: Thu, 24 Nov 2016 22:13:38 +0100 +Subject: [PATCH] Fix PHP 7 build + +--- + ast.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ast.c b/ast.c +index 4c4095d..62a9f48 100644 +--- a/ast.c ++++ b/ast.c +@@ -405,7 +405,7 @@ static void ast_fill_children_ht(HashTable *ht, zend_ast *ast, zend_long version + ast_to_zval(&child_zv, child->child[0], version); + #else + } else if (version >= 35 && ast->kind == ZEND_AST_ARRAY +- && ast->attr == ZEND_ARRAY_SYNTAX_LIST) { ++ && ast->attr == ZEND_ARRAY_SYNTAX_LIST && child != NULL) { + /* Emulate ARRAY_ELEM list */ + zval ch0, ch1; + ast_to_zval(&ch0, child, version); -- cgit