https://wiki.php.net/rfc/deprecate_dynamic_properties
was approved and merged into php 8.2.
Dynamic (undeclared) properties will be forbidden without
`#[AllowDynamicProperties]` in the next major release (9.0).
A separate followup question would be whether to include
`#[AllowDynamicProperties]` on the Node class declaration
or to instead do something similar to nikic/php-parser and add a dedicated
attributes array property for any applications using this library to
track state on nodes.
Fix phpstan notice
checkToken only supports an integer, but started getting passed an array
after supporting intersection types (`['|', '&']`).
Fix a few other type signatures
Pure intersection types were approved and merged into 8.1
https://wiki.php.net/rfc/pure-intersection-types
Note that this is permissive - php itself does not allow union types and
intersection types to be combined right now.
Fixes#354
Fixes parsing of references and bitwise `&` in php 8.1
Raise the minimum php version from 7.0 to 7.2.
Depend on phpunit 8 for local development
Unify method names for Node and Token to getFullStartPosition and getStartPosition
(Consistently end public API methods with Position).
Avoid the need for callers to check if an object is a Node/Token before
calling a method.
Convert UnsetIntrinsicExpression to UnsetStatement - it can only be used
as a statement.
Unify previously split up lists into a single list in some AST node
properties (initially done that way for backward compatibility)
Clean up unnecessary special case for throw
- This continues to be parsed as an ExpressionStatement with the same
precedence
Rename throwStatement to throwExpression in test file names.
Drop support for byRefToken in ArgumentExpression - it's a syntax error
in php 7.0+ and is prohibited in php 5.4+.
Convert the foo and otherFooList to fooList for union types in catch
name lists, parameters, properties, and return union types.
Remove ThrowStatement in favor of ThrowExpression for php 8.0.
Remove EchoExpression in favor of EchoStatement - echo cannot be used as
an expression.
Remove statement from NamedLabelStatement - it's always null since a
named label is a single statement by itself.
TODO: Consistently support MissingToken in a single-element list in cases where
a non-empty list is required, such as after `?` in types
(php 8.0 union types forbid combining `?` with multiple types)
TODO: Check for any regressions in diagnostics
TODO: Validate that this can be used with real projects
Supports parsing https://wiki.php.net/rfc/enumerations
These tests pass locally after modifying the local installation of
phpunit 6 to workaround php 8.1 incompatibilities for `private function` and
$GLOBALS
Also, fix placeholder for T_NULLSAFE_OBJECT_OPERATOR prior to php 8.0.
This didn't matter in practice because
token_get_all never returns the constant that would be used in a key
prior to php 8.0
Enums are similar to classes, but:
- They forbid instance properties (and static properties)
- They allow `case` statements, which are the only allowed instances of
the object. Those may or may not have an associated int/string type.
The parse grammar seems to allow parsing any type
but the compiler enforces that it's empty, an integer, or a string.
Each attribute group must have 1 or more elements.
The same approach is used for closure use element lists.
php > #[] class X{}
Parse error: syntax error, unexpected token "]" in php shell code
on line 1
The label is a standalone statement just like any other statement.
It isn't associated with the next statement by PHP's parser.
E.g. `while (false) label: echo "test\n";` echoes "test".
Fixes#154
Whenever Travis provides a stable 8.0 label, that can be switched to.
Currently, though, that's not available. 8.0snapshot could not be
installed when I tried.
PHPUnit is too outdated for it to support 8.0.
Yaml treats `:` as a dictionary, so use the multi-line string syntax.
I forgot that anonymous classes were parsed into an
ObjectCreationExpression instead.
Also support attributes there, cause a diagnostic to be emitted if the
attribute group(s) aren't followed by the `class` keyword.
For #320