refactoring: remove "StmtTraitMethodRef" node
This commit is contained in:
parent
c29e8ec0e0
commit
c0465f9605
@ -24032,44 +24032,36 @@ func TestStmtTraitUse_Modifier(t *testing.T) {
|
|||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 43,
|
EndPos: 43,
|
||||||
},
|
},
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
Method: &ast.Identifier{
|
IdentifierTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("one"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
IdentifierTkn: &token.Token{
|
FreeFloating: []*token.Token{
|
||||||
ID: token.T_STRING,
|
{
|
||||||
Value: []byte("one"),
|
ID: token.T_WHITESPACE,
|
||||||
Position: &position.Position{
|
Value: []byte(" "),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 30,
|
EndLine: 1,
|
||||||
EndPos: 33,
|
StartPos: 29,
|
||||||
},
|
EndPos: 30,
|
||||||
FreeFloating: []*token.Token{
|
|
||||||
{
|
|
||||||
ID: token.T_WHITESPACE,
|
|
||||||
Value: []byte(" "),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 29,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Value: []byte("one"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("one"),
|
||||||
},
|
},
|
||||||
AsTkn: &token.Token{
|
AsTkn: &token.Token{
|
||||||
ID: token.T_AS,
|
ID: token.T_AS,
|
||||||
@ -24453,44 +24445,36 @@ func TestStmtTraitUse_AliasModifier(t *testing.T) {
|
|||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 47,
|
EndPos: 47,
|
||||||
},
|
},
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
Method: &ast.Identifier{
|
IdentifierTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("one"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
IdentifierTkn: &token.Token{
|
FreeFloating: []*token.Token{
|
||||||
ID: token.T_STRING,
|
{
|
||||||
Value: []byte("one"),
|
ID: token.T_WHITESPACE,
|
||||||
Position: &position.Position{
|
Value: []byte(" "),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 30,
|
EndLine: 1,
|
||||||
EndPos: 33,
|
StartPos: 29,
|
||||||
},
|
EndPos: 30,
|
||||||
FreeFloating: []*token.Token{
|
|
||||||
{
|
|
||||||
ID: token.T_WHITESPACE,
|
|
||||||
Value: []byte(" "),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 29,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Value: []byte("one"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("one"),
|
||||||
},
|
},
|
||||||
AsTkn: &token.Token{
|
AsTkn: &token.Token{
|
||||||
ID: token.T_AS,
|
ID: token.T_AS,
|
||||||
@ -24905,83 +24889,75 @@ func TestStmtTraitUse_Adaptions(t *testing.T) {
|
|||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 58,
|
EndPos: 58,
|
||||||
},
|
},
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: &ast.NameName{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 38,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
Trait: &ast.NameName{
|
Parts: []ast.Vertex{
|
||||||
Position: &position.Position{
|
&ast.NameNamePart{
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 30,
|
EndLine: 1,
|
||||||
EndPos: 33,
|
StartPos: 30,
|
||||||
},
|
EndPos: 33,
|
||||||
Parts: []ast.Vertex{
|
},
|
||||||
&ast.NameNamePart{
|
StringTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("Bar"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
StringTkn: &token.Token{
|
FreeFloating: []*token.Token{
|
||||||
ID: token.T_STRING,
|
{
|
||||||
Value: []byte("Bar"),
|
ID: token.T_WHITESPACE,
|
||||||
Position: &position.Position{
|
Value: []byte(" "),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 30,
|
EndLine: 1,
|
||||||
EndPos: 33,
|
StartPos: 29,
|
||||||
},
|
EndPos: 30,
|
||||||
FreeFloating: []*token.Token{
|
|
||||||
{
|
|
||||||
ID: token.T_WHITESPACE,
|
|
||||||
Value: []byte(" "),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 29,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Value: []byte("Bar"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("Bar"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DoubleColonTkn: &token.Token{
|
},
|
||||||
ID: token.T_PAAMAYIM_NEKUDOTAYIM,
|
DoubleColonTkn: &token.Token{
|
||||||
Value: []byte("::"),
|
ID: token.T_PAAMAYIM_NEKUDOTAYIM,
|
||||||
Position: &position.Position{
|
Value: []byte("::"),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 33,
|
EndLine: 1,
|
||||||
EndPos: 35,
|
StartPos: 33,
|
||||||
},
|
EndPos: 35,
|
||||||
},
|
},
|
||||||
Method: &ast.Identifier{
|
},
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Position: &position.Position{
|
||||||
|
StartLine: 1,
|
||||||
|
EndLine: 1,
|
||||||
|
StartPos: 35,
|
||||||
|
EndPos: 38,
|
||||||
|
},
|
||||||
|
IdentifierTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("one"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 35,
|
StartPos: 35,
|
||||||
EndPos: 38,
|
EndPos: 38,
|
||||||
},
|
},
|
||||||
IdentifierTkn: &token.Token{
|
|
||||||
ID: token.T_STRING,
|
|
||||||
Value: []byte("one"),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 35,
|
|
||||||
EndPos: 38,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Value: []byte("one"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("one"),
|
||||||
},
|
},
|
||||||
InsteadofTkn: &token.Token{
|
InsteadofTkn: &token.Token{
|
||||||
ID: token.T_INSTEADOF,
|
ID: token.T_INSTEADOF,
|
||||||
@ -25119,83 +25095,75 @@ func TestStmtTraitUse_Adaptions(t *testing.T) {
|
|||||||
StartPos: 60,
|
StartPos: 60,
|
||||||
EndPos: 75,
|
EndPos: 75,
|
||||||
},
|
},
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: &ast.NameName{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 60,
|
StartPos: 60,
|
||||||
EndPos: 68,
|
EndPos: 63,
|
||||||
},
|
},
|
||||||
Trait: &ast.NameName{
|
Parts: []ast.Vertex{
|
||||||
Position: &position.Position{
|
&ast.NameNamePart{
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 60,
|
EndLine: 1,
|
||||||
EndPos: 63,
|
StartPos: 60,
|
||||||
},
|
EndPos: 63,
|
||||||
Parts: []ast.Vertex{
|
},
|
||||||
&ast.NameNamePart{
|
StringTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("Baz"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 60,
|
StartPos: 60,
|
||||||
EndPos: 63,
|
EndPos: 63,
|
||||||
},
|
},
|
||||||
StringTkn: &token.Token{
|
FreeFloating: []*token.Token{
|
||||||
ID: token.T_STRING,
|
{
|
||||||
Value: []byte("Baz"),
|
ID: token.T_WHITESPACE,
|
||||||
Position: &position.Position{
|
Value: []byte(" "),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 60,
|
EndLine: 1,
|
||||||
EndPos: 63,
|
StartPos: 59,
|
||||||
},
|
EndPos: 60,
|
||||||
FreeFloating: []*token.Token{
|
|
||||||
{
|
|
||||||
ID: token.T_WHITESPACE,
|
|
||||||
Value: []byte(" "),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 59,
|
|
||||||
EndPos: 60,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Value: []byte("Baz"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("Baz"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DoubleColonTkn: &token.Token{
|
},
|
||||||
ID: token.T_PAAMAYIM_NEKUDOTAYIM,
|
DoubleColonTkn: &token.Token{
|
||||||
Value: []byte("::"),
|
ID: token.T_PAAMAYIM_NEKUDOTAYIM,
|
||||||
Position: &position.Position{
|
Value: []byte("::"),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 63,
|
EndLine: 1,
|
||||||
EndPos: 65,
|
StartPos: 63,
|
||||||
},
|
EndPos: 65,
|
||||||
},
|
},
|
||||||
Method: &ast.Identifier{
|
},
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Position: &position.Position{
|
||||||
|
StartLine: 1,
|
||||||
|
EndLine: 1,
|
||||||
|
StartPos: 65,
|
||||||
|
EndPos: 68,
|
||||||
|
},
|
||||||
|
IdentifierTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("one"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 65,
|
StartPos: 65,
|
||||||
EndPos: 68,
|
EndPos: 68,
|
||||||
},
|
},
|
||||||
IdentifierTkn: &token.Token{
|
|
||||||
ID: token.T_STRING,
|
|
||||||
Value: []byte("one"),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 65,
|
|
||||||
EndPos: 68,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Value: []byte("one"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("one"),
|
||||||
},
|
},
|
||||||
AsTkn: &token.Token{
|
AsTkn: &token.Token{
|
||||||
ID: token.T_AS,
|
ID: token.T_AS,
|
||||||
|
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -2295,10 +2295,12 @@ trait_precedence:
|
|||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUsePrecedence{
|
$$ = &ast.StmtTraitUsePrecedence{
|
||||||
Position: yylex.(*Parser).builder.NewNodeNodeListPosition($1, $3.(*ast.ParserSeparatedList).Items),
|
Position: yylex.(*Parser).builder.NewNodeNodeListPosition($1, $3.(*ast.ParserSeparatedList).Items),
|
||||||
Ref: $1,
|
Trait: $1.(*ast.TraitMethodRef).Trait,
|
||||||
InsteadofTkn: $2,
|
DoubleColonTkn: $1.(*ast.TraitMethodRef).DoubleColonTkn,
|
||||||
Insteadof: $3.(*ast.ParserSeparatedList).Items,
|
Method: $1.(*ast.TraitMethodRef).Method,
|
||||||
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
|
InsteadofTkn: $2,
|
||||||
|
Insteadof: $3.(*ast.ParserSeparatedList).Items,
|
||||||
|
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -2322,7 +2324,7 @@ trait_reference_list:
|
|||||||
trait_method_reference:
|
trait_method_reference:
|
||||||
T_STRING
|
T_STRING
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitMethodRef{
|
$$ = &ast.TraitMethodRef{
|
||||||
Position: yylex.(*Parser).builder.NewTokenPosition($1),
|
Position: yylex.(*Parser).builder.NewTokenPosition($1),
|
||||||
Method: &ast.Identifier{
|
Method: &ast.Identifier{
|
||||||
Position: yylex.(*Parser).builder.NewTokenPosition($1),
|
Position: yylex.(*Parser).builder.NewTokenPosition($1),
|
||||||
@ -2340,7 +2342,7 @@ trait_method_reference:
|
|||||||
trait_method_reference_fully_qualified:
|
trait_method_reference_fully_qualified:
|
||||||
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING
|
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitMethodRef{
|
$$ = &ast.TraitMethodRef{
|
||||||
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3),
|
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3),
|
||||||
Trait: $1,
|
Trait: $1,
|
||||||
DoubleColonTkn: $2,
|
DoubleColonTkn: $2,
|
||||||
@ -2357,10 +2359,12 @@ trait_alias:
|
|||||||
trait_method_reference T_AS trait_modifiers T_STRING
|
trait_method_reference T_AS trait_modifiers T_STRING
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUseAlias{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4),
|
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4),
|
||||||
Ref: $1,
|
Trait: $1.(*ast.TraitMethodRef).Trait,
|
||||||
AsTkn: $2,
|
DoubleColonTkn: $1.(*ast.TraitMethodRef).DoubleColonTkn,
|
||||||
Modifier: $3,
|
Method: $1.(*ast.TraitMethodRef).Method,
|
||||||
|
AsTkn: $2,
|
||||||
|
Modifier: $3,
|
||||||
Alias: &ast.Identifier{
|
Alias: &ast.Identifier{
|
||||||
Position: yylex.(*Parser).builder.NewTokenPosition($4),
|
Position: yylex.(*Parser).builder.NewTokenPosition($4),
|
||||||
IdentifierTkn: $4,
|
IdentifierTkn: $4,
|
||||||
@ -2371,10 +2375,12 @@ trait_alias:
|
|||||||
| trait_method_reference T_AS member_modifier
|
| trait_method_reference T_AS member_modifier
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUseAlias{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Position: yylex.(*Parser).builder.NewNodesPosition($1, $3),
|
Position: yylex.(*Parser).builder.NewNodesPosition($1, $3),
|
||||||
Ref: $1,
|
Trait: $1.(*ast.TraitMethodRef).Trait,
|
||||||
AsTkn: $2,
|
DoubleColonTkn: $1.(*ast.TraitMethodRef).DoubleColonTkn,
|
||||||
Modifier: $3,
|
Method: $1.(*ast.TraitMethodRef).Method,
|
||||||
|
AsTkn: $2,
|
||||||
|
Modifier: $3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -26000,44 +26000,36 @@ func TestStmtTraitUse_Modifier(t *testing.T) {
|
|||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 43,
|
EndPos: 43,
|
||||||
},
|
},
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
Method: &ast.Identifier{
|
IdentifierTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("one"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
IdentifierTkn: &token.Token{
|
FreeFloating: []*token.Token{
|
||||||
ID: token.T_STRING,
|
{
|
||||||
Value: []byte("one"),
|
ID: token.T_WHITESPACE,
|
||||||
Position: &position.Position{
|
Value: []byte(" "),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 30,
|
EndLine: 1,
|
||||||
EndPos: 33,
|
StartPos: 29,
|
||||||
},
|
EndPos: 30,
|
||||||
FreeFloating: []*token.Token{
|
|
||||||
{
|
|
||||||
ID: token.T_WHITESPACE,
|
|
||||||
Value: []byte(" "),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 29,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Value: []byte("one"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("one"),
|
||||||
},
|
},
|
||||||
AsTkn: &token.Token{
|
AsTkn: &token.Token{
|
||||||
ID: token.T_AS,
|
ID: token.T_AS,
|
||||||
@ -26421,44 +26413,36 @@ func TestStmtTraitUse_AliasModifier(t *testing.T) {
|
|||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 47,
|
EndPos: 47,
|
||||||
},
|
},
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
Method: &ast.Identifier{
|
IdentifierTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("one"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
IdentifierTkn: &token.Token{
|
FreeFloating: []*token.Token{
|
||||||
ID: token.T_STRING,
|
{
|
||||||
Value: []byte("one"),
|
ID: token.T_WHITESPACE,
|
||||||
Position: &position.Position{
|
Value: []byte(" "),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 30,
|
EndLine: 1,
|
||||||
EndPos: 33,
|
StartPos: 29,
|
||||||
},
|
EndPos: 30,
|
||||||
FreeFloating: []*token.Token{
|
|
||||||
{
|
|
||||||
ID: token.T_WHITESPACE,
|
|
||||||
Value: []byte(" "),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 29,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Value: []byte("one"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("one"),
|
||||||
},
|
},
|
||||||
AsTkn: &token.Token{
|
AsTkn: &token.Token{
|
||||||
ID: token.T_AS,
|
ID: token.T_AS,
|
||||||
@ -26873,83 +26857,75 @@ func TestStmtTraitUse_Adaptions(t *testing.T) {
|
|||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 58,
|
EndPos: 58,
|
||||||
},
|
},
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: &ast.NameName{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 38,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
Trait: &ast.NameName{
|
Parts: []ast.Vertex{
|
||||||
Position: &position.Position{
|
&ast.NameNamePart{
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 30,
|
EndLine: 1,
|
||||||
EndPos: 33,
|
StartPos: 30,
|
||||||
},
|
EndPos: 33,
|
||||||
Parts: []ast.Vertex{
|
},
|
||||||
&ast.NameNamePart{
|
StringTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("Bar"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 30,
|
StartPos: 30,
|
||||||
EndPos: 33,
|
EndPos: 33,
|
||||||
},
|
},
|
||||||
StringTkn: &token.Token{
|
FreeFloating: []*token.Token{
|
||||||
ID: token.T_STRING,
|
{
|
||||||
Value: []byte("Bar"),
|
ID: token.T_WHITESPACE,
|
||||||
Position: &position.Position{
|
Value: []byte(" "),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 30,
|
EndLine: 1,
|
||||||
EndPos: 33,
|
StartPos: 29,
|
||||||
},
|
EndPos: 30,
|
||||||
FreeFloating: []*token.Token{
|
|
||||||
{
|
|
||||||
ID: token.T_WHITESPACE,
|
|
||||||
Value: []byte(" "),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 29,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Value: []byte("Bar"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("Bar"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DoubleColonTkn: &token.Token{
|
},
|
||||||
ID: token.T_PAAMAYIM_NEKUDOTAYIM,
|
DoubleColonTkn: &token.Token{
|
||||||
Value: []byte("::"),
|
ID: token.T_PAAMAYIM_NEKUDOTAYIM,
|
||||||
Position: &position.Position{
|
Value: []byte("::"),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 33,
|
EndLine: 1,
|
||||||
EndPos: 35,
|
StartPos: 33,
|
||||||
},
|
EndPos: 35,
|
||||||
},
|
},
|
||||||
Method: &ast.Identifier{
|
},
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Position: &position.Position{
|
||||||
|
StartLine: 1,
|
||||||
|
EndLine: 1,
|
||||||
|
StartPos: 35,
|
||||||
|
EndPos: 38,
|
||||||
|
},
|
||||||
|
IdentifierTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("one"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 35,
|
StartPos: 35,
|
||||||
EndPos: 38,
|
EndPos: 38,
|
||||||
},
|
},
|
||||||
IdentifierTkn: &token.Token{
|
|
||||||
ID: token.T_STRING,
|
|
||||||
Value: []byte("one"),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 35,
|
|
||||||
EndPos: 38,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Value: []byte("one"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("one"),
|
||||||
},
|
},
|
||||||
InsteadofTkn: &token.Token{
|
InsteadofTkn: &token.Token{
|
||||||
ID: token.T_INSTEADOF,
|
ID: token.T_INSTEADOF,
|
||||||
@ -27087,83 +27063,75 @@ func TestStmtTraitUse_Adaptions(t *testing.T) {
|
|||||||
StartPos: 60,
|
StartPos: 60,
|
||||||
EndPos: 75,
|
EndPos: 75,
|
||||||
},
|
},
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: &ast.NameName{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 60,
|
StartPos: 60,
|
||||||
EndPos: 68,
|
EndPos: 63,
|
||||||
},
|
},
|
||||||
Trait: &ast.NameName{
|
Parts: []ast.Vertex{
|
||||||
Position: &position.Position{
|
&ast.NameNamePart{
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 60,
|
EndLine: 1,
|
||||||
EndPos: 63,
|
StartPos: 60,
|
||||||
},
|
EndPos: 63,
|
||||||
Parts: []ast.Vertex{
|
},
|
||||||
&ast.NameNamePart{
|
StringTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("Baz"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 60,
|
StartPos: 60,
|
||||||
EndPos: 63,
|
EndPos: 63,
|
||||||
},
|
},
|
||||||
StringTkn: &token.Token{
|
FreeFloating: []*token.Token{
|
||||||
ID: token.T_STRING,
|
{
|
||||||
Value: []byte("Baz"),
|
ID: token.T_WHITESPACE,
|
||||||
Position: &position.Position{
|
Value: []byte(" "),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 60,
|
EndLine: 1,
|
||||||
EndPos: 63,
|
StartPos: 59,
|
||||||
},
|
EndPos: 60,
|
||||||
FreeFloating: []*token.Token{
|
|
||||||
{
|
|
||||||
ID: token.T_WHITESPACE,
|
|
||||||
Value: []byte(" "),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 59,
|
|
||||||
EndPos: 60,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Value: []byte("Baz"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("Baz"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DoubleColonTkn: &token.Token{
|
},
|
||||||
ID: token.T_PAAMAYIM_NEKUDOTAYIM,
|
DoubleColonTkn: &token.Token{
|
||||||
Value: []byte("::"),
|
ID: token.T_PAAMAYIM_NEKUDOTAYIM,
|
||||||
Position: &position.Position{
|
Value: []byte("::"),
|
||||||
StartLine: 1,
|
Position: &position.Position{
|
||||||
EndLine: 1,
|
StartLine: 1,
|
||||||
StartPos: 63,
|
EndLine: 1,
|
||||||
EndPos: 65,
|
StartPos: 63,
|
||||||
},
|
EndPos: 65,
|
||||||
},
|
},
|
||||||
Method: &ast.Identifier{
|
},
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Position: &position.Position{
|
||||||
|
StartLine: 1,
|
||||||
|
EndLine: 1,
|
||||||
|
StartPos: 65,
|
||||||
|
EndPos: 68,
|
||||||
|
},
|
||||||
|
IdentifierTkn: &token.Token{
|
||||||
|
ID: token.T_STRING,
|
||||||
|
Value: []byte("one"),
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
EndLine: 1,
|
EndLine: 1,
|
||||||
StartPos: 65,
|
StartPos: 65,
|
||||||
EndPos: 68,
|
EndPos: 68,
|
||||||
},
|
},
|
||||||
IdentifierTkn: &token.Token{
|
|
||||||
ID: token.T_STRING,
|
|
||||||
Value: []byte("one"),
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 65,
|
|
||||||
EndPos: 68,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Value: []byte("one"),
|
|
||||||
},
|
},
|
||||||
|
Value: []byte("one"),
|
||||||
},
|
},
|
||||||
AsTkn: &token.Token{
|
AsTkn: &token.Token{
|
||||||
ID: token.T_AS,
|
ID: token.T_AS,
|
||||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -2132,11 +2132,13 @@ trait_precedence:
|
|||||||
absolute_trait_method_reference T_INSTEADOF name_list
|
absolute_trait_method_reference T_INSTEADOF name_list
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUsePrecedence{
|
$$ = &ast.StmtTraitUsePrecedence{
|
||||||
Position: yylex.(*Parser).builder.NewNodeNodeListPosition($1, $3.(*ast.ParserSeparatedList).Items),
|
Position: yylex.(*Parser).builder.NewNodeNodeListPosition($1, $3.(*ast.ParserSeparatedList).Items),
|
||||||
Ref: $1,
|
Trait: $1.(*ast.TraitMethodRef).Trait,
|
||||||
InsteadofTkn: $2,
|
DoubleColonTkn: $1.(*ast.TraitMethodRef).DoubleColonTkn,
|
||||||
Insteadof: $3.(*ast.ParserSeparatedList).Items,
|
Method: $1.(*ast.TraitMethodRef).Method,
|
||||||
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
|
InsteadofTkn: $2,
|
||||||
|
Insteadof: $3.(*ast.ParserSeparatedList).Items,
|
||||||
|
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -2145,9 +2147,11 @@ trait_alias:
|
|||||||
trait_method_reference T_AS T_STRING
|
trait_method_reference T_AS T_STRING
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUseAlias{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3),
|
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3),
|
||||||
Ref: $1,
|
Trait: $1.(*ast.TraitMethodRef).Trait,
|
||||||
AsTkn: $2,
|
DoubleColonTkn: $1.(*ast.TraitMethodRef).DoubleColonTkn,
|
||||||
|
Method: $1.(*ast.TraitMethodRef).Method,
|
||||||
|
AsTkn: $2,
|
||||||
Alias: &ast.Identifier{
|
Alias: &ast.Identifier{
|
||||||
Position: yylex.(*Parser).builder.NewTokenPosition($3),
|
Position: yylex.(*Parser).builder.NewTokenPosition($3),
|
||||||
IdentifierTkn: $3,
|
IdentifierTkn: $3,
|
||||||
@ -2158,9 +2162,11 @@ trait_alias:
|
|||||||
| trait_method_reference T_AS reserved_non_modifiers
|
| trait_method_reference T_AS reserved_non_modifiers
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUseAlias{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3),
|
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3),
|
||||||
Ref: $1,
|
Trait: $1.(*ast.TraitMethodRef).Trait,
|
||||||
AsTkn: $2,
|
DoubleColonTkn: $1.(*ast.TraitMethodRef).DoubleColonTkn,
|
||||||
|
Method: $1.(*ast.TraitMethodRef).Method,
|
||||||
|
AsTkn: $2,
|
||||||
Alias: &ast.Identifier{
|
Alias: &ast.Identifier{
|
||||||
Position: yylex.(*Parser).builder.NewTokenPosition($3),
|
Position: yylex.(*Parser).builder.NewTokenPosition($3),
|
||||||
IdentifierTkn: $3,
|
IdentifierTkn: $3,
|
||||||
@ -2171,10 +2177,12 @@ trait_alias:
|
|||||||
| trait_method_reference T_AS member_modifier identifier
|
| trait_method_reference T_AS member_modifier identifier
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUseAlias{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4),
|
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $4),
|
||||||
Ref: $1,
|
Trait: $1.(*ast.TraitMethodRef).Trait,
|
||||||
AsTkn: $2,
|
DoubleColonTkn: $1.(*ast.TraitMethodRef).DoubleColonTkn,
|
||||||
Modifier: $3,
|
Method: $1.(*ast.TraitMethodRef).Method,
|
||||||
|
AsTkn: $2,
|
||||||
|
Modifier: $3,
|
||||||
Alias: &ast.Identifier{
|
Alias: &ast.Identifier{
|
||||||
Position: yylex.(*Parser).builder.NewTokenPosition($4),
|
Position: yylex.(*Parser).builder.NewTokenPosition($4),
|
||||||
IdentifierTkn: $4,
|
IdentifierTkn: $4,
|
||||||
@ -2185,10 +2193,12 @@ trait_alias:
|
|||||||
| trait_method_reference T_AS member_modifier
|
| trait_method_reference T_AS member_modifier
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUseAlias{
|
$$ = &ast.StmtTraitUseAlias{
|
||||||
Position: yylex.(*Parser).builder.NewNodesPosition($1, $3),
|
Position: yylex.(*Parser).builder.NewNodesPosition($1, $3),
|
||||||
Ref: $1,
|
Trait: $1.(*ast.TraitMethodRef).Trait,
|
||||||
AsTkn: $2,
|
DoubleColonTkn: $1.(*ast.TraitMethodRef).DoubleColonTkn,
|
||||||
Modifier: $3,
|
Method: $1.(*ast.TraitMethodRef).Method,
|
||||||
|
AsTkn: $2,
|
||||||
|
Modifier: $3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -2196,7 +2206,7 @@ trait_alias:
|
|||||||
trait_method_reference:
|
trait_method_reference:
|
||||||
identifier
|
identifier
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitMethodRef{
|
$$ = &ast.TraitMethodRef{
|
||||||
Position: yylex.(*Parser).builder.NewTokenPosition($1),
|
Position: yylex.(*Parser).builder.NewTokenPosition($1),
|
||||||
Method: &ast.Identifier{
|
Method: &ast.Identifier{
|
||||||
Position: yylex.(*Parser).builder.NewTokenPosition($1),
|
Position: yylex.(*Parser).builder.NewTokenPosition($1),
|
||||||
@ -2214,7 +2224,7 @@ trait_method_reference:
|
|||||||
absolute_trait_method_reference:
|
absolute_trait_method_reference:
|
||||||
name T_PAAMAYIM_NEKUDOTAYIM identifier
|
name T_PAAMAYIM_NEKUDOTAYIM identifier
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitMethodRef{
|
$$ = &ast.TraitMethodRef{
|
||||||
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3),
|
Position: yylex.(*Parser).builder.NewNodeTokenPosition($1, $3),
|
||||||
Trait: $1,
|
Trait: $1,
|
||||||
DoubleColonTkn: $2,
|
DoubleColonTkn: $2,
|
||||||
|
@ -64,7 +64,6 @@ type NodeVisitor interface {
|
|||||||
StmtSwitch(n *StmtSwitch)
|
StmtSwitch(n *StmtSwitch)
|
||||||
StmtThrow(n *StmtThrow)
|
StmtThrow(n *StmtThrow)
|
||||||
StmtTrait(n *StmtTrait)
|
StmtTrait(n *StmtTrait)
|
||||||
StmtTraitMethodRef(n *StmtTraitMethodRef)
|
|
||||||
StmtTraitUse(n *StmtTraitUse)
|
StmtTraitUse(n *StmtTraitUse)
|
||||||
StmtTraitUseAlias(n *StmtTraitUseAlias)
|
StmtTraitUseAlias(n *StmtTraitUseAlias)
|
||||||
StmtTraitUsePrecedence(n *StmtTraitUsePrecedence)
|
StmtTraitUsePrecedence(n *StmtTraitUsePrecedence)
|
||||||
|
@ -937,22 +937,6 @@ func (n *StmtTrait) GetPosition() *position.Position {
|
|||||||
return n.Position
|
return n.Position
|
||||||
}
|
}
|
||||||
|
|
||||||
// StmtTraitMethodRef node
|
|
||||||
type StmtTraitMethodRef struct {
|
|
||||||
Position *position.Position
|
|
||||||
Trait Vertex
|
|
||||||
DoubleColonTkn *token.Token
|
|
||||||
Method Vertex
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *StmtTraitMethodRef) Accept(v NodeVisitor) {
|
|
||||||
v.StmtTraitMethodRef(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *StmtTraitMethodRef) GetPosition() *position.Position {
|
|
||||||
return n.Position
|
|
||||||
}
|
|
||||||
|
|
||||||
// StmtTraitUse node
|
// StmtTraitUse node
|
||||||
type StmtTraitUse struct {
|
type StmtTraitUse struct {
|
||||||
Position *position.Position
|
Position *position.Position
|
||||||
@ -975,12 +959,14 @@ func (n *StmtTraitUse) GetPosition() *position.Position {
|
|||||||
|
|
||||||
// StmtTraitUseAlias node
|
// StmtTraitUseAlias node
|
||||||
type StmtTraitUseAlias struct {
|
type StmtTraitUseAlias struct {
|
||||||
Position *position.Position
|
Position *position.Position
|
||||||
Ref Vertex
|
Trait Vertex
|
||||||
AsTkn *token.Token
|
DoubleColonTkn *token.Token
|
||||||
Modifier Vertex
|
Method Vertex
|
||||||
Alias Vertex
|
AsTkn *token.Token
|
||||||
SemiColonTkn *token.Token
|
Modifier Vertex
|
||||||
|
Alias Vertex
|
||||||
|
SemiColonTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtTraitUseAlias) Accept(v NodeVisitor) {
|
func (n *StmtTraitUseAlias) Accept(v NodeVisitor) {
|
||||||
@ -993,12 +979,14 @@ func (n *StmtTraitUseAlias) GetPosition() *position.Position {
|
|||||||
|
|
||||||
// StmtTraitUsePrecedence node
|
// StmtTraitUsePrecedence node
|
||||||
type StmtTraitUsePrecedence struct {
|
type StmtTraitUsePrecedence struct {
|
||||||
Position *position.Position
|
Position *position.Position
|
||||||
Ref Vertex
|
Trait Vertex
|
||||||
InsteadofTkn *token.Token
|
DoubleColonTkn *token.Token
|
||||||
Insteadof []Vertex
|
Method Vertex
|
||||||
SeparatorTkns []*token.Token
|
InsteadofTkn *token.Token
|
||||||
SemiColonTkn *token.Token
|
Insteadof []Vertex
|
||||||
|
SeparatorTkns []*token.Token
|
||||||
|
SemiColonTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtTraitUsePrecedence) Accept(v NodeVisitor) {
|
func (n *StmtTraitUsePrecedence) Accept(v NodeVisitor) {
|
||||||
@ -2734,3 +2722,19 @@ func (n *ReturnType) Accept(v NodeVisitor) {
|
|||||||
func (n *ReturnType) GetPosition() *position.Position {
|
func (n *ReturnType) GetPosition() *position.Position {
|
||||||
return n.Position
|
return n.Position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TraitMethodRef node
|
||||||
|
type TraitMethodRef struct {
|
||||||
|
Position *position.Position
|
||||||
|
Trait Vertex
|
||||||
|
DoubleColonTkn *token.Token
|
||||||
|
Method Vertex
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *TraitMethodRef) Accept(v NodeVisitor) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *TraitMethodRef) GetPosition() *position.Position {
|
||||||
|
return n.Position
|
||||||
|
}
|
||||||
|
@ -776,23 +776,6 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
|||||||
}
|
}
|
||||||
t.visitor.Leave("Stmts", false)
|
t.visitor.Leave("Stmts", false)
|
||||||
}
|
}
|
||||||
case *ast.StmtTraitMethodRef:
|
|
||||||
if nn == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !t.visitor.EnterNode(nn) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if nn.Trait != nil {
|
|
||||||
t.visitor.Enter("Trait", true)
|
|
||||||
t.Traverse(nn.Trait)
|
|
||||||
t.visitor.Leave("Trait", true)
|
|
||||||
}
|
|
||||||
if nn.Method != nil {
|
|
||||||
t.visitor.Enter("Method", true)
|
|
||||||
t.Traverse(nn.Method)
|
|
||||||
t.visitor.Leave("Method", true)
|
|
||||||
}
|
|
||||||
case *ast.StmtTraitUse:
|
case *ast.StmtTraitUse:
|
||||||
if nn == nil {
|
if nn == nil {
|
||||||
return
|
return
|
||||||
@ -821,10 +804,15 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
|||||||
if !t.visitor.EnterNode(nn) {
|
if !t.visitor.EnterNode(nn) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if nn.Ref != nil {
|
if nn.Trait != nil {
|
||||||
t.visitor.Enter("Ref", true)
|
t.visitor.Enter("Trait", true)
|
||||||
t.Traverse(nn.Ref)
|
t.Traverse(nn.Trait)
|
||||||
t.visitor.Leave("Ref", true)
|
t.visitor.Leave("Trait", true)
|
||||||
|
}
|
||||||
|
if nn.Method != nil {
|
||||||
|
t.visitor.Enter("Method", true)
|
||||||
|
t.Traverse(nn.Method)
|
||||||
|
t.visitor.Leave("Method", true)
|
||||||
}
|
}
|
||||||
if nn.Modifier != nil {
|
if nn.Modifier != nil {
|
||||||
t.visitor.Enter("Modifier", true)
|
t.visitor.Enter("Modifier", true)
|
||||||
@ -843,10 +831,15 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
|||||||
if !t.visitor.EnterNode(nn) {
|
if !t.visitor.EnterNode(nn) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if nn.Ref != nil {
|
if nn.Trait != nil {
|
||||||
t.visitor.Enter("Ref", true)
|
t.visitor.Enter("Trait", true)
|
||||||
t.Traverse(nn.Ref)
|
t.Traverse(nn.Trait)
|
||||||
t.visitor.Leave("Ref", true)
|
t.visitor.Leave("Trait", true)
|
||||||
|
}
|
||||||
|
if nn.Method != nil {
|
||||||
|
t.visitor.Enter("Method", true)
|
||||||
|
t.Traverse(nn.Method)
|
||||||
|
t.visitor.Leave("Method", true)
|
||||||
}
|
}
|
||||||
if nn.Insteadof != nil {
|
if nn.Insteadof != nil {
|
||||||
t.visitor.Enter("Insteadof", false)
|
t.visitor.Enter("Insteadof", false)
|
||||||
|
@ -824,19 +824,6 @@ func (v *Dumper) StmtTrait(n *ast.StmtTrait) {
|
|||||||
v.print(v.indent, "},\n")
|
v.print(v.indent, "},\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dumper) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
|
||||||
v.print(0, "&ast.StmtTraitMethodRef{\n")
|
|
||||||
v.indent++
|
|
||||||
|
|
||||||
v.dumpPosition(n.Position)
|
|
||||||
v.dumpVertex("Trait", n.Trait)
|
|
||||||
v.dumpToken("DoubleColonTkn", n.DoubleColonTkn)
|
|
||||||
v.dumpVertex("Method", n.Method)
|
|
||||||
|
|
||||||
v.indent--
|
|
||||||
v.print(v.indent, "},\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *Dumper) StmtTraitUse(n *ast.StmtTraitUse) {
|
func (v *Dumper) StmtTraitUse(n *ast.StmtTraitUse) {
|
||||||
v.print(0, "&ast.StmtTraitUse{\n")
|
v.print(0, "&ast.StmtTraitUse{\n")
|
||||||
v.indent++
|
v.indent++
|
||||||
@ -859,7 +846,9 @@ func (v *Dumper) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
|||||||
v.indent++
|
v.indent++
|
||||||
|
|
||||||
v.dumpPosition(n.Position)
|
v.dumpPosition(n.Position)
|
||||||
v.dumpVertex("Ref", n.Ref)
|
v.dumpVertex("Trait", n.Trait)
|
||||||
|
v.dumpToken("DoubleColonTkn", n.DoubleColonTkn)
|
||||||
|
v.dumpVertex("Method", n.Method)
|
||||||
v.dumpToken("AsTkn", n.AsTkn)
|
v.dumpToken("AsTkn", n.AsTkn)
|
||||||
v.dumpVertex("Modifier", n.Modifier)
|
v.dumpVertex("Modifier", n.Modifier)
|
||||||
v.dumpVertex("Alias", n.Alias)
|
v.dumpVertex("Alias", n.Alias)
|
||||||
@ -874,7 +863,9 @@ func (v *Dumper) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) {
|
|||||||
v.indent++
|
v.indent++
|
||||||
|
|
||||||
v.dumpPosition(n.Position)
|
v.dumpPosition(n.Position)
|
||||||
v.dumpVertex("Ref", n.Ref)
|
v.dumpVertex("Trait", n.Trait)
|
||||||
|
v.dumpToken("DoubleColonTkn", n.DoubleColonTkn)
|
||||||
|
v.dumpVertex("Method", n.Method)
|
||||||
v.dumpToken("InsteadofTkn", n.InsteadofTkn)
|
v.dumpToken("InsteadofTkn", n.InsteadofTkn)
|
||||||
v.dumpVertexList("Insteadof", n.Insteadof)
|
v.dumpVertexList("Insteadof", n.Insteadof)
|
||||||
v.dumpTokenList("SeparatorTkns", n.SeparatorTkns)
|
v.dumpTokenList("SeparatorTkns", n.SeparatorTkns)
|
||||||
|
@ -858,15 +858,6 @@ func (f *formatter) StmtTrait(n *ast.StmtTrait) {
|
|||||||
n.CloseCurlyBracketTkn = f.newToken('}', []byte("}"))
|
n.CloseCurlyBracketTkn = f.newToken('}', []byte("}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *formatter) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
|
||||||
if n.Trait != nil {
|
|
||||||
n.Trait.Accept(f)
|
|
||||||
n.DoubleColonTkn = f.newToken(token.T_PAAMAYIM_NEKUDOTAYIM, []byte("::"))
|
|
||||||
}
|
|
||||||
|
|
||||||
n.Method.Accept(f)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *formatter) StmtTraitUse(n *ast.StmtTraitUse) {
|
func (f *formatter) StmtTraitUse(n *ast.StmtTraitUse) {
|
||||||
n.UseTkn = f.newToken(token.T_USE, []byte("use"))
|
n.UseTkn = f.newToken(token.T_USE, []byte("use"))
|
||||||
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
||||||
@ -897,7 +888,12 @@ func (f *formatter) StmtTraitUse(n *ast.StmtTraitUse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *formatter) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
func (f *formatter) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
||||||
n.Ref.Accept(f)
|
if n.Trait != nil {
|
||||||
|
n.Trait.Accept(f)
|
||||||
|
n.DoubleColonTkn = f.newToken(token.T_PAAMAYIM_NEKUDOTAYIM, []byte("::"))
|
||||||
|
}
|
||||||
|
|
||||||
|
n.Method.Accept(f)
|
||||||
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
||||||
n.AsTkn = f.newToken(token.T_AS, []byte("as"))
|
n.AsTkn = f.newToken(token.T_AS, []byte("as"))
|
||||||
|
|
||||||
@ -915,7 +911,12 @@ func (f *formatter) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *formatter) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) {
|
func (f *formatter) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) {
|
||||||
n.Ref.Accept(f)
|
if n.Trait != nil {
|
||||||
|
n.Trait.Accept(f)
|
||||||
|
n.DoubleColonTkn = f.newToken(token.T_PAAMAYIM_NEKUDOTAYIM, []byte("::"))
|
||||||
|
}
|
||||||
|
|
||||||
|
n.Method.Accept(f)
|
||||||
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
||||||
n.InsteadofTkn = f.newToken(token.T_INSTEADOF, []byte("insteadof"))
|
n.InsteadofTkn = f.newToken(token.T_INSTEADOF, []byte("insteadof"))
|
||||||
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
||||||
|
@ -2360,59 +2360,6 @@ func TestFormatter_StmtTrait(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFormatter_StmtTraitMethodRef(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
n := &ast.StmtTraitMethodRef{
|
|
||||||
Method: &ast.Identifier{
|
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
|
||||||
n.Accept(f)
|
|
||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
|
||||||
n.Accept(p)
|
|
||||||
|
|
||||||
expected := `foo`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFormatter_StmtTraitMethodRef_Trait(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
n := &ast.StmtTraitMethodRef{
|
|
||||||
Trait: &ast.NameName{
|
|
||||||
Parts: []ast.Vertex{
|
|
||||||
&ast.NameNamePart{
|
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Method: &ast.Identifier{
|
|
||||||
Value: []byte("bar"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
|
||||||
n.Accept(f)
|
|
||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
|
||||||
n.Accept(p)
|
|
||||||
|
|
||||||
expected := `foo::bar`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFormatter_StmtTraitUse(t *testing.T) {
|
func TestFormatter_StmtTraitUse(t *testing.T) {
|
||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
@ -2471,10 +2418,8 @@ func TestFormatter_StmtTraitUse_Adaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Adaptations: []ast.Vertex{
|
Adaptations: []ast.Vertex{
|
||||||
&ast.StmtTraitUseAlias{
|
&ast.StmtTraitUseAlias{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Method: &ast.Identifier{
|
Value: []byte("foo"),
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Alias: &ast.Identifier{
|
Alias: &ast.Identifier{
|
||||||
Value: []byte("baz"),
|
Value: []byte("baz"),
|
||||||
@ -2503,10 +2448,8 @@ func TestFormatter_StmtTraitUseAlias(t *testing.T) {
|
|||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
n := &ast.StmtTraitUseAlias{
|
n := &ast.StmtTraitUseAlias{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Method: &ast.Identifier{
|
Value: []byte("foo"),
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Modifier: &ast.Identifier{
|
Modifier: &ast.Identifier{
|
||||||
Value: []byte("public"),
|
Value: []byte("public"),
|
||||||
@ -2530,14 +2473,48 @@ func TestFormatter_StmtTraitUseAlias(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFormatter_StmtTraitUseAlias_Trait(t *testing.T) {
|
||||||
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
|
n := &ast.StmtTraitUseAlias{
|
||||||
|
Trait: &ast.NameName{
|
||||||
|
Parts: []ast.Vertex{
|
||||||
|
&ast.NameNamePart{
|
||||||
|
Value: []byte("foo"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Value: []byte("bar"),
|
||||||
|
},
|
||||||
|
Modifier: &ast.Identifier{
|
||||||
|
Value: []byte("public"),
|
||||||
|
},
|
||||||
|
Alias: &ast.Identifier{
|
||||||
|
Value: []byte("baz"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
||||||
|
n.Accept(f)
|
||||||
|
|
||||||
|
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
||||||
|
n.Accept(p)
|
||||||
|
|
||||||
|
expected := `foo::bar as public baz;`
|
||||||
|
actual := o.String()
|
||||||
|
|
||||||
|
if expected != actual {
|
||||||
|
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFormatter_StmtTraitUseAlias_Alias(t *testing.T) {
|
func TestFormatter_StmtTraitUseAlias_Alias(t *testing.T) {
|
||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
n := &ast.StmtTraitUseAlias{
|
n := &ast.StmtTraitUseAlias{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Method: &ast.Identifier{
|
Value: []byte("foo"),
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Alias: &ast.Identifier{
|
Alias: &ast.Identifier{
|
||||||
Value: []byte("bar"),
|
Value: []byte("bar"),
|
||||||
@ -2562,10 +2539,8 @@ func TestFormatter_StmtTraitUseAlias_Modifier(t *testing.T) {
|
|||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
n := &ast.StmtTraitUseAlias{
|
n := &ast.StmtTraitUseAlias{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Method: &ast.Identifier{
|
Value: []byte("foo"),
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Modifier: &ast.Identifier{
|
Modifier: &ast.Identifier{
|
||||||
Value: []byte("public"),
|
Value: []byte("public"),
|
||||||
@ -2590,10 +2565,8 @@ func TestFormatter_StmtTraitUsePrecedence(t *testing.T) {
|
|||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
n := &ast.StmtTraitUsePrecedence{
|
n := &ast.StmtTraitUsePrecedence{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Method: &ast.Identifier{
|
||||||
Method: &ast.Identifier{
|
Value: []byte("foo"),
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Insteadof: []ast.Vertex{
|
Insteadof: []ast.Vertex{
|
||||||
&ast.NameName{
|
&ast.NameName{
|
||||||
@ -2627,6 +2600,45 @@ func TestFormatter_StmtTraitUsePrecedence(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFormatter_StmtTraitUsePrecedence_Trait(t *testing.T) {
|
||||||
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
|
n := &ast.StmtTraitUsePrecedence{
|
||||||
|
Trait: &ast.NameName{
|
||||||
|
Parts: []ast.Vertex{
|
||||||
|
&ast.NameNamePart{
|
||||||
|
Value: []byte("foo"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Value: []byte("bar"),
|
||||||
|
},
|
||||||
|
Insteadof: []ast.Vertex{
|
||||||
|
&ast.NameName{
|
||||||
|
Parts: []ast.Vertex{
|
||||||
|
&ast.NameNamePart{
|
||||||
|
Value: []byte("baz"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
||||||
|
n.Accept(f)
|
||||||
|
|
||||||
|
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
||||||
|
n.Accept(p)
|
||||||
|
|
||||||
|
expected := `foo::bar insteadof baz;`
|
||||||
|
actual := o.String()
|
||||||
|
|
||||||
|
if expected != actual {
|
||||||
|
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestFormatter_StmtTry(t *testing.T) {
|
func TestFormatter_StmtTry(t *testing.T) {
|
||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ func (nsr *NamespaceResolver) StmtTraitUse(n *ast.StmtTraitUse) {
|
|||||||
for _, a := range n.Adaptations {
|
for _, a := range n.Adaptations {
|
||||||
switch aa := a.(type) {
|
switch aa := a.(type) {
|
||||||
case *ast.StmtTraitUsePrecedence:
|
case *ast.StmtTraitUsePrecedence:
|
||||||
refTrait := aa.Ref.(*ast.StmtTraitMethodRef).Trait
|
refTrait := aa.Trait
|
||||||
if refTrait != nil {
|
if refTrait != nil {
|
||||||
nsr.ResolveName(refTrait, "")
|
nsr.ResolveName(refTrait, "")
|
||||||
}
|
}
|
||||||
@ -196,7 +196,7 @@ func (nsr *NamespaceResolver) StmtTraitUse(n *ast.StmtTraitUse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case *ast.StmtTraitUseAlias:
|
case *ast.StmtTraitUseAlias:
|
||||||
refTrait := aa.Ref.(*ast.StmtTraitMethodRef).Trait
|
refTrait := aa.Trait
|
||||||
if refTrait != nil {
|
if refTrait != nil {
|
||||||
nsr.ResolveName(refTrait, "")
|
nsr.ResolveName(refTrait, "")
|
||||||
}
|
}
|
||||||
|
@ -356,18 +356,14 @@ func TestResolveTraitUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Adaptations: []ast.Vertex{
|
Adaptations: []ast.Vertex{
|
||||||
&ast.StmtTraitUsePrecedence{
|
&ast.StmtTraitUsePrecedence{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: fullyQualifiedNameB,
|
||||||
Trait: fullyQualifiedNameB,
|
Method: &ast.Identifier{Value: []byte("foo")},
|
||||||
Method: &ast.Identifier{Value: []byte("foo")},
|
|
||||||
},
|
|
||||||
Insteadof: []ast.Vertex{fullyQualifiedNameBC},
|
Insteadof: []ast.Vertex{fullyQualifiedNameBC},
|
||||||
},
|
},
|
||||||
&ast.StmtTraitUseAlias{
|
&ast.StmtTraitUseAlias{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: relativeNameBC,
|
||||||
Trait: relativeNameBC,
|
Method: &ast.Identifier{Value: []byte("foo")},
|
||||||
Method: &ast.Identifier{Value: []byte("foo")},
|
Alias: &ast.Identifier{Value: []byte("bar")},
|
||||||
},
|
|
||||||
Alias: &ast.Identifier{Value: []byte("bar")},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -194,10 +194,6 @@ func (v *Null) StmtTrait(_ *ast.StmtTrait) {
|
|||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Null) StmtTraitMethodRef(_ *ast.StmtTraitMethodRef) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *Null) StmtTraitUse(_ *ast.StmtTraitUse) {
|
func (v *Null) StmtTraitUse(_ *ast.StmtTraitUse) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -518,12 +518,6 @@ func (p *printer) StmtTrait(n *ast.StmtTrait) {
|
|||||||
p.printToken(n.CloseCurlyBracketTkn, []byte("}"))
|
p.printToken(n.CloseCurlyBracketTkn, []byte("}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *printer) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
|
||||||
p.printNode(n.Trait)
|
|
||||||
p.printToken(n.DoubleColonTkn, p.ifNode(n.Trait, []byte("::")))
|
|
||||||
p.printNode(n.Method)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *printer) StmtTraitUse(n *ast.StmtTraitUse) {
|
func (p *printer) StmtTraitUse(n *ast.StmtTraitUse) {
|
||||||
p.printToken(n.UseTkn, []byte("use"))
|
p.printToken(n.UseTkn, []byte("use"))
|
||||||
p.printSeparatedList(n.Traits, n.SeparatorTkns, []byte(","))
|
p.printSeparatedList(n.Traits, n.SeparatorTkns, []byte(","))
|
||||||
@ -534,7 +528,9 @@ func (p *printer) StmtTraitUse(n *ast.StmtTraitUse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *printer) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
func (p *printer) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
||||||
p.printNode(n.Ref)
|
p.printNode(n.Trait)
|
||||||
|
p.printToken(n.DoubleColonTkn, p.ifNode(n.Trait, []byte("::")))
|
||||||
|
p.printNode(n.Method)
|
||||||
p.printToken(n.AsTkn, []byte("as"))
|
p.printToken(n.AsTkn, []byte("as"))
|
||||||
p.printNode(n.Modifier)
|
p.printNode(n.Modifier)
|
||||||
p.printNode(n.Alias)
|
p.printNode(n.Alias)
|
||||||
@ -542,7 +538,9 @@ func (p *printer) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *printer) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) {
|
func (p *printer) StmtTraitUsePrecedence(n *ast.StmtTraitUsePrecedence) {
|
||||||
p.printNode(n.Ref)
|
p.printNode(n.Trait)
|
||||||
|
p.printToken(n.DoubleColonTkn, p.ifNode(n.Trait, []byte("::")))
|
||||||
|
p.printNode(n.Method)
|
||||||
p.printToken(n.InsteadofTkn, []byte("insteadof"))
|
p.printToken(n.InsteadofTkn, []byte("insteadof"))
|
||||||
p.printSeparatedList(n.Insteadof, n.SeparatorTkns, []byte(","))
|
p.printSeparatedList(n.Insteadof, n.SeparatorTkns, []byte(","))
|
||||||
p.printToken(n.SemiColonTkn, []byte(";"))
|
p.printToken(n.SemiColonTkn, []byte(";"))
|
||||||
|
@ -4452,50 +4452,13 @@ func TestPrinterPrintStmtThrow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrinterPrintStmtTraitMethodRef(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
|
||||||
n := &ast.StmtTraitMethodRef{
|
|
||||||
Method: &ast.Identifier{Value: []byte("a")},
|
|
||||||
}
|
|
||||||
n.Accept(p)
|
|
||||||
|
|
||||||
expected := `a`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrinterPrintStmtTraitMethodRefFull(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
|
||||||
n := &ast.StmtTraitMethodRef{
|
|
||||||
Trait: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
|
||||||
Method: &ast.Identifier{Value: []byte("a")},
|
|
||||||
}
|
|
||||||
n.Accept(p)
|
|
||||||
|
|
||||||
expected := `Foo::a`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrinterPrintStmtTraitUseAlias(t *testing.T) {
|
func TestPrinterPrintStmtTraitUseAlias(t *testing.T) {
|
||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
||||||
n := &ast.StmtTraitUseAlias{
|
n := &ast.StmtTraitUseAlias{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
Trait: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
Method: &ast.Identifier{Value: []byte("a")},
|
||||||
Method: &ast.Identifier{Value: []byte("a")},
|
|
||||||
},
|
|
||||||
Modifier: &ast.Identifier{Value: []byte("public")},
|
Modifier: &ast.Identifier{Value: []byte("public")},
|
||||||
Alias: &ast.Identifier{Value: []byte("b")},
|
Alias: &ast.Identifier{Value: []byte("b")},
|
||||||
}
|
}
|
||||||
@ -4514,10 +4477,8 @@ func TestPrinterPrintStmtTraitUsePrecedence(t *testing.T) {
|
|||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
||||||
n := &ast.StmtTraitUsePrecedence{
|
n := &ast.StmtTraitUsePrecedence{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
Trait: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
Method: &ast.Identifier{Value: []byte("a")},
|
||||||
Method: &ast.Identifier{Value: []byte("a")},
|
|
||||||
},
|
|
||||||
Insteadof: []ast.Vertex{
|
Insteadof: []ast.Vertex{
|
||||||
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Bar")}}},
|
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Bar")}}},
|
||||||
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Baz")}}},
|
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Baz")}}},
|
||||||
@ -4564,11 +4525,9 @@ func TestPrinterPrintStmtTraitAdaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Adaptations: []ast.Vertex{
|
Adaptations: []ast.Vertex{
|
||||||
&ast.StmtTraitUseAlias{
|
&ast.StmtTraitUseAlias{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Trait: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
Trait: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
Method: &ast.Identifier{Value: []byte("a")},
|
||||||
Method: &ast.Identifier{Value: []byte("a")},
|
Alias: &ast.Identifier{Value: []byte("b")},
|
||||||
},
|
|
||||||
Alias: &ast.Identifier{Value: []byte("b")},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user