mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-12-11 16:49:43 +01:00
4c22c62783
Adds support for PHP 8 attributes, represented using `AttrGroup` nodes containing `Attribute` nodes. The `attrGroup` subnode is added to all nodes that can have attributes. This is still missing FPPP support. Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
91 lines
2.5 KiB
Plaintext
91 lines
2.5 KiB
Plaintext
Property promotion
|
|
-----
|
|
<?php
|
|
|
|
class Point {
|
|
public function __construct(
|
|
public float $x = 0.0,
|
|
protected array $y = [],
|
|
private string $z = 'hello'
|
|
) {}
|
|
}
|
|
-----
|
|
!!php7
|
|
array(
|
|
0: Stmt_Class(
|
|
attrGroups: array(
|
|
)
|
|
flags: 0
|
|
name: Identifier(
|
|
name: Point
|
|
)
|
|
extends: null
|
|
implements: array(
|
|
)
|
|
stmts: array(
|
|
0: Stmt_ClassMethod(
|
|
attrGroups: array(
|
|
)
|
|
flags: MODIFIER_PUBLIC (1)
|
|
byRef: false
|
|
name: Identifier(
|
|
name: __construct
|
|
)
|
|
params: array(
|
|
0: Param(
|
|
attrGroups: array(
|
|
)
|
|
flags: MODIFIER_PUBLIC (1)
|
|
type: Identifier(
|
|
name: float
|
|
)
|
|
byRef: false
|
|
variadic: false
|
|
var: Expr_Variable(
|
|
name: x
|
|
)
|
|
default: Scalar_DNumber(
|
|
value: 0
|
|
)
|
|
)
|
|
1: Param(
|
|
attrGroups: array(
|
|
)
|
|
flags: MODIFIER_PROTECTED (2)
|
|
type: Identifier(
|
|
name: array
|
|
)
|
|
byRef: false
|
|
variadic: false
|
|
var: Expr_Variable(
|
|
name: y
|
|
)
|
|
default: Expr_Array(
|
|
items: array(
|
|
)
|
|
)
|
|
)
|
|
2: Param(
|
|
attrGroups: array(
|
|
)
|
|
flags: MODIFIER_PRIVATE (4)
|
|
type: Identifier(
|
|
name: string
|
|
)
|
|
byRef: false
|
|
variadic: false
|
|
var: Expr_Variable(
|
|
name: z
|
|
)
|
|
default: Scalar_String(
|
|
value: hello
|
|
)
|
|
)
|
|
)
|
|
returnType: null
|
|
stmts: array(
|
|
)
|
|
)
|
|
)
|
|
)
|
|
) |