PHP 8 (#1)
PHP 8 Update
- nullsafe operator (?->)
- Remove (real) cast
- Named arguments
- Remove (unset) cast
- Remove {} access
- match expression
- Union types in type hints and static typehint
- Block catch without variable
- Trailing comma in parameter lists
- throw can be used as an expression
- Concatenation precedence
- Declaring properties in the constructor
- Attributes
- Names in the namespace are treated as a single token
- Trailing comma in closure use list
- Check that ::class on object works
- Deferencable changes and arbitrary expressions in new/instanceof
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/z7zmey/php-parser/internal/php5"
|
||||
"github.com/z7zmey/php-parser/internal/php7"
|
||||
"github.com/z7zmey/php-parser/internal/php8"
|
||||
"github.com/z7zmey/php-parser/internal/scanner"
|
||||
"github.com/z7zmey/php-parser/pkg/ast"
|
||||
"github.com/z7zmey/php-parser/pkg/conf"
|
||||
@@ -20,6 +21,9 @@ var (
|
||||
|
||||
php7RangeStart = &version.Version{Major: 7}
|
||||
php7RangeEnd = &version.Version{Major: 7, Minor: 4}
|
||||
|
||||
php8RangeStart = &version.Version{Major: 8}
|
||||
php8RangeEnd = &version.Version{Major: 8, Minor: 1}
|
||||
)
|
||||
|
||||
// Parser interface
|
||||
@@ -49,5 +53,12 @@ func Parse(src []byte, config conf.Config) (ast.Vertex, error) {
|
||||
return parser.GetRootNode(), nil
|
||||
}
|
||||
|
||||
if config.Version.InRange(php8RangeStart, php8RangeEnd) {
|
||||
lexer := php8.NewLexer(src, config)
|
||||
parser = php8.NewParser(lexer, config)
|
||||
parser.Parse()
|
||||
return parser.GetRootNode(), nil
|
||||
}
|
||||
|
||||
return nil, ErrVersionOutOfRange
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user