Skip to content

Commit dd264ec

Browse files
committed
Deprecate AST version 40
1 parent 60acf78 commit dd264ec

32 files changed

+111
-61
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,9 @@ This version normalizes the AST to PHP 7.2 format.
535535
* An `object` type annotation now returns an `AST_TYPE` with `TYPE_OBJECT` flag, rather than
536536
treating `object` as a class name.
537537

538-
### 40 (supported)
538+
### 40 (deprecated)
539539

540-
Supported since 2017-01-18.
540+
Supported since 2017-01-18. Deprecated since 2018-10-06.
541541

542542
* `AST_COALESCE` is now represented as an `AST_BINARY_OP` with flag `BINARY_COALESCE`.
543543
* For `AST_NAME` nodes with `NAME_FQ` the leading backslash is now dropped if syntax like

ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ static const zend_long versions[] = {30, 35, 40, 45, 50};
782782
static const size_t versions_count = sizeof(versions)/sizeof(versions[0]);
783783

784784
static inline zend_bool ast_version_deprecated(zend_long version) {
785-
return version == 30 || version == 35;
785+
return version == 30 || version == 35 || version == 40;
786786
}
787787

788788
static zend_string *ast_version_info() {

tests/001.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ function test(Type $arg = XYZ) : Ret {
2020
}
2121
PHP;
2222

23-
echo ast_dump(ast\parse_code($code, $version=40));
23+
echo ast_dump(ast\parse_code($code, $version=50));
2424
--EXPECT--
2525
AST_STMT_LIST
2626
0: AST_FUNC_DECL
2727
flags: 0
28-
name: test
29-
docComment: /** Test function */
28+
name: "test"
29+
docComment: "/** Test function */"
3030
params: AST_PARAM_LIST
3131
0: AST_PARAM
3232
flags: 0
@@ -70,3 +70,4 @@ AST_STMT_LIST
7070
returnType: AST_NAME
7171
flags: NAME_NOT_FQ (1)
7272
name: "Ret"
73+
__declId: 0

tests/002.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ assert($fn->kind == ast\AST_FUNC_DECL);
1515

1616
?>
1717
===DONE===
18-
--EXPECT--
18+
--EXPECTF--
19+
20+
Deprecated: ast\parse_code(): Version 40 is deprecated in %s on line %d
1921
===DONE===

tests/array_destructuring.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ list('foo' => $a, 'bar' => $b) = $x;
1515
[, [$a]] = $x;
1616
PHP;
1717

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

2020
?>
2121
--EXPECT--

tests/assign_ops.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $a <<= $b;
2121
$a >>= $b;
2222
PHP;
2323

24-
echo ast_dump(ast\parse_code($code, $version=40)), "\n";
24+
echo ast_dump(ast\parse_code($code, $version=50)), "\n";
2525

2626
?>
2727
--EXPECTF--

tests/ast_dump_with_linenos.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ test
2323
}
2424
PHP;
2525

26-
$ast = ast\parse_code($code, $version=40);
26+
$ast = ast\parse_code($code, $version=50);
2727
echo ast_dump($ast, AST_DUMP_LINENOS);
2828

2929
?>
3030
--EXPECT--
3131
AST_STMT_LIST @ 1
3232
0: AST_FUNC_DECL @ 2-9
3333
flags: 0
34-
name: test
34+
name: "test"
35+
docComment: null
3536
params: AST_PARAM_LIST @ 4
3637
uses: null
3738
stmts: AST_STMT_LIST @ 5
@@ -43,3 +44,4 @@ AST_STMT_LIST @ 1
4344
0: AST_VAR @ 7
4445
name: "foo"
4546
returnType: null
47+
__declId: 0

tests/binary_ops.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $a and $b;
1313
$a or $b;
1414
PHP;
1515

16-
echo ast_dump(ast\parse_code($code, $version=40)), "\n";
16+
echo ast_dump(ast\parse_code($code, $version=50)), "\n";
1717

1818
?>
1919
--EXPECT--

tests/class.phpt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ class A extends B implements D, E {
1515
}
1616
PHP;
1717

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

2020
?>
2121
--EXPECTF--
2222
AST_STMT_LIST
2323
0: AST_CLASS
2424
flags: 0
25-
name: A
25+
name: "A"
26+
docComment: null
2627
extends: AST_NAME
2728
flags: NAME_NOT_FQ (1)
2829
name: "B"
@@ -48,21 +49,28 @@ AST_STMT_LIST
4849
0: AST_CONST_ELEM
4950
name: "X"
5051
value: "Y"
52+
docComment: null
5153
1: AST_CONST_ELEM
5254
name: "Y"
5355
value: "X"
56+
docComment: null
5457
2: AST_PROP_DECL
5558
flags: MODIFIER_PUBLIC (%d)
5659
0: AST_PROP_ELEM
5760
name: "foo"
5861
default: null
62+
docComment: null
5963
1: AST_PROP_ELEM
6064
name: "bar"
6165
default: null
66+
docComment: null
6267
3: AST_METHOD
6368
flags: MODIFIER_PUBLIC | MODIFIER_ABSTRACT (%d)
64-
name: test
69+
name: "test"
70+
docComment: null
6571
params: AST_PARAM_LIST
6672
uses: null
6773
stmts: null
6874
returnType: null
75+
__declId: 0
76+
__declId: 1

tests/class_consts.phpt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,50 @@ class Test {
2323
}
2424
PHP;
2525

26-
echo ast_dump(ast\parse_code($code, $version=40));
26+
echo ast_dump(ast\parse_code($code, $version=50));
2727

2828
?>
2929
--EXPECTF--
3030
AST_STMT_LIST
3131
0: AST_CLASS
3232
flags: 0
33-
name: Test
33+
name: "Test"
34+
docComment: null
3435
extends: null
3536
implements: null
3637
stmts: AST_STMT_LIST
3738
0: AST_CLASS_CONST_DECL
3839
flags: MODIFIER_PUBLIC (%d)
3940
0: AST_CONST_ELEM
40-
docComment: /** Doc A */
4141
name: "A"
4242
value: 1
43+
docComment: "/** Doc A */"
4344
1: AST_CLASS_CONST_DECL
4445
flags: MODIFIER_PUBLIC (%d)
4546
0: AST_CONST_ELEM
4647
name: "B"
4748
value: 2
49+
docComment: null
4850
2: AST_CLASS_CONST_DECL
4951
flags: MODIFIER_PROTECTED (%d)
5052
0: AST_CONST_ELEM
5153
name: "C"
5254
value: 3
55+
docComment: null
5356
3: AST_CLASS_CONST_DECL
5457
flags: MODIFIER_PRIVATE (%d)
5558
0: AST_CONST_ELEM
5659
name: "D"
5760
value: 4
61+
docComment: null
5862
4: AST_CLASS_CONST_DECL
5963
flags: MODIFIER_PUBLIC (%d)
6064
0: AST_CONST_ELEM
61-
docComment: /** Doc E */
6265
name: "E"
6366
value: 5
67+
docComment: "/** Doc E */"
6468
1: AST_CONST_ELEM
65-
docComment: /** Doc F */
6669
name: "F"
6770
value: 6
71+
docComment: "/** Doc F */"
72+
__declId: 0

0 commit comments

Comments
 (0)