-
Notifications
You must be signed in to change notification settings - Fork 16
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
PHP 8 #1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`.
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.
# Conflicts: # internal/php8/php8.go
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`.
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.
…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
🚀🚀🚀🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All development was done on a fork of @i582: i582/php-parser#1.
nullsafe
operator (?->
) i582/php-parser#10(real)
cast i582/php-parser#11(unset)
cast i582/php-parser#15{}
access i582/php-parser#17match
expression i582/php-parser#19static
typehint i582/php-parser#21catch
without variable i582/php-parser#23throw
can be used as an expression i582/php-parser#27::class
on object works i582/php-parser#40new
/instanceof
i582/php-parser#42