Skip to content

Commit 0414087

Browse files
committed
Mention in docs that ast\Node\Decl is no longer used
Mark versions 45 and 50 as supported.
1 parent edc2c4c commit 0414087

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ Usage
3737

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

4242
```php
43-
$ast = ast\parse_code('<?php ...', $version=40);
43+
$ast = ast\parse_code('<?php ...', $version=50);
4444
// or
45-
$ast = ast\parse_file('file.php', $version=40);
45+
$ast = ast\parse_file('file.php', $version=50);
4646
```
4747

4848
The abstract syntax tree returned by these functions consists of `ast\Node` objects.
@@ -72,8 +72,8 @@ The `children` property contains an array of child-nodes. These children can be
7272
`ast\Node` objects or plain values. The meaning of the children is node-specific and should be
7373
deduced from context or by looking at the [parser definition][parser].
7474

75-
Function and class declarations use `ast\Node\Decl` objects instead, which specify a number of
76-
additional properties:
75+
Prior to AST version 50, function and class declarations used `ast\Node\Decl` objects instead,
76+
which specify a number of additional properties:
7777

7878
```php
7979
namespace ast\Node;
@@ -86,9 +86,9 @@ class Decl extends Node {
8686
}
8787
```
8888

89-
`endLineno` provides the end line number of the declaration, `name` contains the name of the
90-
function or class (can be `null` for anonymous classes) and `docComment` contains the preceding
91-
doc comment or `null` if no doc comment was used.
89+
As of AST version 50, `ast\Node\Decl` objects are no longer used. Instead the `name` and the
90+
`docComment` will be provided as ordinary child nodes. The `endLineno` is provided as an
91+
(undeclared, dynamic) property on the node.
9292

9393
Simple usage example:
9494

@@ -100,7 +100,7 @@ $code = <<<'EOC'
100100
$var = 42;
101101
EOC;
102102

103-
var_dump(ast\parse_code($code, $version=40));
103+
var_dump(ast\parse_code($code, $version=50));
104104

105105
// Output:
106106
object(ast\Node)#1 (4) {
@@ -157,7 +157,7 @@ $code = <<<'EOC'
157157
$var = 42;
158158
EOC;
159159

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

162162
// Output:
163163
AST_STMT_LIST
@@ -433,7 +433,9 @@ ZEND_AST_USE
433433
Version changelog
434434
-----------------
435435

436-
### 50 (in development)
436+
### 50 (current)
437+
438+
Supported since 2017-07-19.
437439

438440
* `ast\Node\Decl` nodes are no longer generated. AST kinds `AST_FUNCTION`, `AST_METHOD`,
439441
`AST_CLOSURE` and `AST_CLASS` now also use the normal `ast\Node` class. The `name` and
@@ -447,14 +449,16 @@ Version changelog
447449
* `\ast\parse_file` will now consistently return an empty statement list (similar to
448450
`\ast\parse_code`) if it is was passed a zero-byte file. Previously, it would return `null`.
449451

450-
### 45 (in development)
452+
### 45 (supported)
453+
454+
Supported since 2017-07-19.
451455

452456
This version normalizes the AST to PHP 7.2 format.
453457

454458
* An `object` type annotation now returns an `AST_TYPE` with `TYPE_OBJECT` flag, rather than
455459
treating `object` as a class name.
456460

457-
### 40 (current)
461+
### 40 (supported)
458462

459463
Supported since 2017-01-18.
460464

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 40
31+
#define AST_CURRENT_VERSION 50
3232

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

0 commit comments

Comments
 (0)