Skip to content

Commit 78740a2

Browse files
committed
Mark version 30 as current
No point in keeping it experimental if people already rely on the format...
1 parent 81b9b7a commit 78740a2

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ Usage
3939

4040
Code can be parsed using either `ast\parse_code()`, which accepts a code string, or
4141
`ast\parse_file()`, which accepts a file path. Additionally both functions require a `$version`
42-
argument to ensure forward-compatibility. The current version is 20.
42+
argument to ensure forward-compatibility. The current version is 30.
4343

4444
```php
45-
$ast = ast\parse_code('<?php ...', $version=20);
45+
$ast = ast\parse_code('<?php ...', $version=30);
4646
// or
47-
$ast = ast\parse_file('file.php', $version=20);
47+
$ast = ast\parse_file('file.php', $version=30);
4848
```
4949

5050
The abstract syntax tree returned by these functions consists of `ast\Node` objects.
@@ -102,7 +102,7 @@ $code = <<<'EOC'
102102
$var = 42;
103103
EOC;
104104

105-
var_dump(ast\parse_code($code, $version=20));
105+
var_dump(ast\parse_code($code, $version=30));
106106

107107
// Output:
108108
object(ast\Node)#1 (4) {
@@ -121,24 +121,24 @@ object(ast\Node)#1 (4) {
121121
["flags"]=>
122122
int(0)
123123
["lineno"]=>
124-
int(1)
124+
int(2)
125125
["children"]=>
126126
array(2) {
127-
[0]=>
127+
["var"]=>
128128
object(ast\Node)#3 (4) {
129129
["kind"]=>
130130
int(256)
131131
["flags"]=>
132132
int(0)
133133
["lineno"]=>
134-
int(1)
134+
int(2)
135135
["children"]=>
136136
array(1) {
137-
[0]=>
137+
["name"]=>
138138
string(3) "var"
139139
}
140140
}
141-
[1]=>
141+
["expr"]=>
142142
int(42)
143143
}
144144
}
@@ -159,14 +159,14 @@ $code = <<<'EOC'
159159
$var = 42;
160160
EOC;
161161

162-
echo ast_dump(ast\parse_code($code, $version=20)), "\n";
162+
echo ast_dump(ast\parse_code($code, $version=30)), "\n";
163163

164164
// Output:
165165
AST_STMT_LIST
166166
0: AST_ASSIGN
167-
0: AST_VAR
168-
0: "var"
169-
1: 42
167+
var: AST_VAR
168+
name: "var"
169+
expr: 42
170170
```
171171

172172
To additionally show line numbers pass the `AST_DUMP_LINENOS` option as the second argument to
@@ -304,11 +304,11 @@ ast\flags\EXEC_REQUIRE_ONCE
304304
Version changelog
305305
-----------------
306306

307-
### 30 (unstable)
307+
### 30 (current)
308308

309309
* Use string names for child nodes of kinds with fixed length.
310310

311-
### 20 (current)
311+
### 20 (supported)
312312

313313
* `AST_GREATER`, `AST_GREATER_EQUAL`, `AST_OR`, `AST_AND` nodes are now represented using
314314
`AST_BINARY_OP` with flags `BINARY_IS_GREATER`, `BINARY_IS_GREATER_OR_EQUAL`, `BINARY_BOOL_OR`

ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#define AST_CACHE_SLOT_LINENO &AST_G(cache_slots)[2 * 2]
2929
#define AST_CACHE_SLOT_CHILDREN &AST_G(cache_slots)[2 * 3]
3030

31-
#define AST_CURRENT_VERSION 20
31+
#define AST_CURRENT_VERSION 30
3232

3333
/* Additional flags for BINARY_OP */
3434
#define AST_BINARY_IS_GREATER 256

0 commit comments

Comments
 (0)