php8.1: do not resolve reserved name never in NamespaceResolver

This commit is contained in:
Tyler Christensen 2023-04-24 12:44:37 -06:00 committed by Laytan Laats
parent 9281143091
commit e3aaf7bd13
2 changed files with 15 additions and 0 deletions

View File

@ -372,6 +372,8 @@ func (ns *Namespace) ResolveName(nameNode ast.Vertex, aliasType string) (string,
case "object": case "object":
fallthrough fallthrough
case "mixed": // 8.0 case "mixed": // 8.0
fallthrough
case "never": // 8.1
return part, nil return part, nil
} }
} }

View File

@ -861,6 +861,12 @@ func TestDoNotResolveReservedNames(t *testing.T) {
}, },
} }
nameNever := &ast.Name{
Parts: []ast.Vertex{
&ast.NamePart{Value: []byte("never")},
},
}
function := &ast.StmtFunction{ function := &ast.StmtFunction{
Name: &ast.Identifier{Value: []byte("bar")}, Name: &ast.Identifier{Value: []byte("bar")},
Params: []ast.Vertex{ Params: []ast.Vertex{
@ -912,6 +918,12 @@ func TestDoNotResolveReservedNames(t *testing.T) {
Name: &ast.Identifier{Value: []byte("Mixed")}, Name: &ast.Identifier{Value: []byte("Mixed")},
}, },
}, },
&ast.Parameter{
Type: nameNever,
Var: &ast.ExprVariable{
Name: &ast.Identifier{Value: []byte("Never")},
},
},
}, },
} }
@ -938,6 +950,7 @@ func TestDoNotResolveReservedNames(t *testing.T) {
nameIterable: "iterable", nameIterable: "iterable",
nameObject: "object", nameObject: "object",
nameMixed: "mixed", nameMixed: "mixed",
nameNever: "never",
} }
nsResolver := nsresolver.NewNamespaceResolver() nsResolver := nsresolver.NewNamespaceResolver()