create TraitAdaptationList node

This commit is contained in:
z7zmey
2018-04-29 22:34:24 +03:00
parent 8fc4c60bfe
commit f8d9d6d7c2
14 changed files with 1492 additions and 1326 deletions

View File

@@ -152,7 +152,7 @@ func (nsr *NamespaceResolver) EnterNode(w walker.Walkable) bool {
nsr.ResolveName(t, "")
}
for _, a := range n.Adaptations {
for _, a := range n.TraitAdaptationList.Adaptations {
switch aa := a.(type) {
case *stmt.TraitUsePrecedence:
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait

View File

@@ -43,8 +43,8 @@ func TestResolveStaticCall(t *testing.T) {
},
},
&expr.StaticCall{
Class: nameBC,
Call: &node.Identifier{Value: "foo"},
Class: nameBC,
Call: &node.Identifier{Value: "foo"},
ArgumentList: &node.ArgumentList{},
},
},
@@ -134,7 +134,7 @@ func TestResolveNew(t *testing.T) {
},
},
&expr.New{
Class: nameBC,
Class: nameBC,
ArgumentList: &node.ArgumentList{},
},
},
@@ -242,7 +242,7 @@ func TestResolveFunctionCall(t *testing.T) {
},
},
&expr.FunctionCall{
Function: nameB,
Function: nameB,
ArgumentList: &node.ArgumentList{},
},
},
@@ -323,11 +323,11 @@ func TestResolveGroupUse(t *testing.T) {
Constant: nameC,
},
&expr.FunctionCall{
Function: nameF,
Function: nameF,
ArgumentList: &node.ArgumentList{},
},
&expr.FunctionCall{
Function: nameE,
Function: nameE,
ArgumentList: &node.ArgumentList{},
},
},
@@ -368,20 +368,22 @@ func TestResolveTraitUse(t *testing.T) {
nameB,
relativeNameB,
},
Adaptations: []node.Node{
&stmt.TraitUsePrecedence{
Ref: &stmt.TraitMethodRef{
Trait: fullyQualifiedNameB,
Method: &node.Identifier{Value: "foo"},
TraitAdaptationList: &stmt.TraitAdaptationList{
Adaptations: []node.Node{
&stmt.TraitUsePrecedence{
Ref: &stmt.TraitMethodRef{
Trait: fullyQualifiedNameB,
Method: &node.Identifier{Value: "foo"},
},
Insteadof: []node.Node{fullyQualifiedNameBC},
},
Insteadof: []node.Node{fullyQualifiedNameBC},
},
&stmt.TraitUseAlias{
Ref: &stmt.TraitMethodRef{
Trait: relativeNameBC,
Method: &node.Identifier{Value: "foo"},
&stmt.TraitUseAlias{
Ref: &stmt.TraitMethodRef{
Trait: relativeNameBC,
Method: &node.Identifier{Value: "foo"},
},
Alias: &node.Identifier{Value: "bar"},
},
Alias: &node.Identifier{Value: "bar"},
},
},
},
@@ -658,8 +660,8 @@ func TestResolveNamespaces(t *testing.T) {
},
},
&expr.StaticCall{
Class: nameFG,
Call: &node.Identifier{Value: "foo"},
Class: nameFG,
Call: &node.Identifier{Value: "foo"},
ArgumentList: &node.ArgumentList{},
},
&stmt.Namespace{
@@ -676,13 +678,13 @@ func TestResolveNamespaces(t *testing.T) {
},
},
&expr.StaticCall{
Class: relativeNameCE,
Call: &node.Identifier{Value: "foo"},
Class: relativeNameCE,
Call: &node.Identifier{Value: "foo"},
ArgumentList: &node.ArgumentList{},
},
&expr.StaticCall{
Class: nameCF,
Call: &node.Identifier{Value: "foo"},
Class: nameCF,
Call: &node.Identifier{Value: "foo"},
ArgumentList: &node.ArgumentList{},
},
},
@@ -708,8 +710,8 @@ func TestResolveStaticCallDinamicClassName(t *testing.T) {
ast := &stmt.StmtList{
Stmts: []node.Node{
&expr.StaticCall{
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &node.Identifier{Value: "foo"},
Class: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
Call: &node.Identifier{Value: "foo"},
ArgumentList: &node.ArgumentList{},
},
},