Similar to 'void', it's a compile time error to use void as a
parameter/property type, not a parse time error.
But `static` is a parse error.
(It can also be used in union types)
Remove redundant tokens added to merged returnTypeDeclarationTokens
Closes#373Closes#372
Support php 8.2's Disjunctive Normal Form Types
(allowing parenthesized intersection types of 2 or more types in union types)
https://wiki.php.net/rfc/dnf_typesCloses#372
Any expression can be used as of 8.0 without an unexpected syntax error.
In encapsulated strings,
`"${a->prop}"` is equivalent to `"{${(a->prop)}}"` in php 8.0 and a
syntax error in previous php versions.
(Get the property `prop` of the global constant `a` (constants can be
objects in php 8.1), then get the variable with the name equal to that
string)
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.