Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8 #1

Merged
merged 35 commits into from
Jul 30, 2021
Merged

PHP 8 #1

merged 35 commits into from
Jul 30, 2021

Conversation

i582 and others added 27 commits July 24, 2021 22:21
Added full copy of PHP 7 parser without changes.

Since there will be changes in the lexer, a copy
of the common PHP 5 and PHP 7 lexer has been moved
to the php8 folder of the parser.

Added test for PHP 8 printer.

Added PHP 8 generation commands to Makefile.

Added a new range of versions for PHP 8.
…nside grammar rules (#7)

The Position Generator is now part of the Builder.
The changes affected the lexer, now `?->` is treated as a single token.
4 new rules have been added to the parser, one for calling a method 
and 3 for fetching a property, since a property fetch can be used in 
more places.

Added a new token type `T_NULLSAFE_OBJECT_OPERATOR`.

The code for the grammar rules for method calls and property fetch 
has been moved to `Builder`.
The changes affected the lexer, the mapping `(real)` and `T_DOUBLE_CAST` were removed.
Now casting to real will raise a parser error: `The (real) cast has been removed, use (float) instead`.
Added a new grammar rule to the parser for named arguments.

The code for the grammar rules for argument has been moved
to `Builder`.
The changes affected the lexer, the mapping `(unset)` and
`T_UNSET_CAST` was removed.
Now casting to real will raise a parser error: 
`The (unset) cast is no longer supported`.
The changes affected the parser, now an error will be
generated when accessing with curly braces, but the AST
will be fully built.
The changes affect the lexer, a new type of token `T_MATCH`
has been added.

In parser added new rules to the grammar, and
added rules for parsing lists (`non_empty_expr_list` and
`expr_list_allow_comma`).
Added new grammar rules, as in PHP-Parser:
- `union_type`
- `type_expr_without_static`
- `type_without_static`
- `union_type_without_static`
- `optional_type_without_static`

Renamed `return_type` with `optional_return_type` to more closely
match the PHP-Parser grammar.

Removed grammar rule `optional_type` since it is not used now.

Added the `Builder.NewSeparatedListWithTwoElements` method to 
create lists with two elements at once.

Moved the code from the grammar rules to the `Builder` methods.
Added following methods:
- `NewNameType`
- `NewNullableType`
- `NewUnionType`
- `NewReturnType`
Added new grammar rules for variables:
- `plain_variable`
- `optional_plain_variable`

The first has replaced the simple use of `T_VARIABLE`, now there
is `plain_variable`, as in PHP-Parser, the second describes the
place where the variable may not be, as in the case of `catch`.

`catch_name_list` renamed to `name_union` as in PHP-Parser.

The code for creating `try` and `catch` has been moved to the `Builder`,
two methods have been added to it:
- `NewTry`
- `NewCatch`

The `NewEmptySeparatedList` method has also been added to create an
empty list.
Changed grammar rules `parameter_list` and `non_empty_parameter_list`.
Added a new grammar rule for the `throw` expression.

Added new node type `ExprThrow`.

For backward compatibility reasons, `throw` expressions that
are standalone are converted to `StmtThrow` as in PHP-Parser.

The code for the grammar rules for creating statements from
expressions, as well as for creating `ExprThrow` and `StmtThrow`
is moved to the `Builder`.

Added a new type of test `ParserDumpTestSuite`.
echo "sum: " . $a + $b;

// PHP would previously interpret it like this:
echo ("sum: " . $a) + $b;

// PHP 8 will make it so that it's interpreted like this:
echo "sum: " . ($a + $b);
The code for creating the parameters and identifiers has been
moved to the `Builder.NewParameter` and `Builder.NewIdentifier` methods.

The grammar rules `is_reference` and `is_variadic` have been renamed
to `optional_arg_ref` and `optional_ellipsis` as in PHP-Parser.

Added a new grammar rule `optional_visibility_modifier` to describe
visibility modifiers for properties.
Since the 'compile' command contains some additional logic,
if you just compile the grammar file, then the error level
will be different, which is why errors appear in the tests.
A new token type `T_ATTRIBUTE` has been added to the lexer created if `#[` is encountered.

Added several grammar rules:
- `attribute_decl`
- `attribute_group`
- `attribute`
- `optional_class_modifiers`
- `optional_attributes`
- `attributes`

Added a new grammar rule `attributed_inline_function` to add attributes to closures and arrow functions.

The code for the grammar rules for functions, anonymous classes, methods, properties, and class constants is moved to the `Builder`.
i582 added 2 commits July 30, 2021 12:40
The grammar rules for `UseList` and `UseGroupList` have been completely rewritten.
Now it is forbidden to use spaces next to the backslash (`\`) in the name.

Added `ParserPrintTestSuite` and `LexerTokenStructTestSuite` suites to the `tester` package.
Added new grammar rule non_empty_lexical_var_list.
i582 and others added 5 commits July 30, 2021 13:04
…nstanceof` (#43)

1. Made encapsed strings fully dereferencable
2. Made constants fully dereferencable
3. Added arbitrary expressions in `new`/`instanceof`
4. Treated magic constants like normal constants
@i582 i582 added the PHP 8 PHP 8 features label Jul 30, 2021
@i582 i582 merged commit 049ce7d into VKCOM:master Jul 30, 2021
@i582 i582 deleted the php8_dev branch July 30, 2021 17:53
@i582 i582 restored the php8_dev branch July 30, 2021 17:53
@ruudk
Copy link
Contributor

ruudk commented Jul 30, 2021

🚀🚀🚀🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PHP 8 PHP 8 features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants