Skip to content

Commit c1bb7d5

Browse files
committed
Emulate PHP 7.0 CONST_ELEM docComment only in version >= 60
1 parent 7eb041f commit c1bb7d5

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@ are listed.
517517

518518
* `AST_FUNC_DECL` and `AST_METHOD` no longer generate a `uses` child. Previously this child was
519519
always `null`.
520+
* `AST_FUNC_CONST_ELEM` now always has a `docComment` child. Previously it was absent on PHP 7.0.
521+
On PHP 7.0 the value is always `null`.
520522

521523
### 50 (current)
522524

ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ static void ast_fill_children_ht(HashTable *ht, zend_ast *ast, ast_state_info_t
643643

644644
#if PHP_VERSION_ID < 70100
645645
/* Emulate docComment on constants, which is not available in PHP 7.0 */
646-
if (state->version >= 50 && ast->kind == ZEND_AST_CONST_ELEM) {
646+
if (state->version >= 60 && ast->kind == ZEND_AST_CONST_ELEM) {
647647
zval tmp;
648648
ZVAL_NULL(&tmp);
649649
zend_hash_add_new(ht, AST_STR(str_docComment), &tmp);

tests/class.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class A extends B implements D, E {
1515
}
1616
PHP;
1717

18-
echo ast_dump(ast\parse_code($code, $version=50));
18+
echo ast_dump(ast\parse_code($code, $version=60));
1919

2020
?>
2121
--EXPECTF--
@@ -69,7 +69,6 @@ AST_STMT_LIST
6969
name: "test"
7070
docComment: null
7171
params: AST_PARAM_LIST
72-
uses: null
7372
stmts: null
7473
returnType: null
7574
__declId: 0

tests/stmt_list.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare(ticks=1) {}
1616
PHP;
1717

1818
echo ast_dump(ast\parse_code($code, $version=35)), "\n";
19-
echo ast_dump(ast\parse_code($code, $version=50)), "\n";
19+
echo ast_dump(ast\parse_code($code, $version=60)), "\n";
2020

2121
?>
2222
--EXPECTF--

0 commit comments

Comments
 (0)