php8.2: do not resolve reserved names {true, false, null}
in NamespaceResolver
This commit is contained in:
parent
e3aaf7bd13
commit
87718f9993
@ -374,6 +374,8 @@ func (ns *Namespace) ResolveName(nameNode ast.Vertex, aliasType string) (string,
|
||||
case "mixed": // 8.0
|
||||
fallthrough
|
||||
case "never": // 8.1
|
||||
fallthrough
|
||||
case "true", "false", "null": // 8.2
|
||||
return part, nil
|
||||
}
|
||||
}
|
||||
|
@ -867,6 +867,24 @@ func TestDoNotResolveReservedNames(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
nameTrue := &ast.Name{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NamePart{Value: []byte("true")},
|
||||
},
|
||||
}
|
||||
|
||||
nameFalse := &ast.Name{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NamePart{Value: []byte("false")},
|
||||
},
|
||||
}
|
||||
|
||||
nameNull := &ast.Name{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NamePart{Value: []byte("null")},
|
||||
},
|
||||
}
|
||||
|
||||
function := &ast.StmtFunction{
|
||||
Name: &ast.Identifier{Value: []byte("bar")},
|
||||
Params: []ast.Vertex{
|
||||
@ -924,6 +942,24 @@ func TestDoNotResolveReservedNames(t *testing.T) {
|
||||
Name: &ast.Identifier{Value: []byte("Never")},
|
||||
},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: nameTrue,
|
||||
Var: &ast.ExprVariable{
|
||||
Name: &ast.Identifier{Value: []byte("True")},
|
||||
},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: nameFalse,
|
||||
Var: &ast.ExprVariable{
|
||||
Name: &ast.Identifier{Value: []byte("False")},
|
||||
},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: nameNull,
|
||||
Var: &ast.ExprVariable{
|
||||
Name: &ast.Identifier{Value: []byte("Null")},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -951,6 +987,9 @@ func TestDoNotResolveReservedNames(t *testing.T) {
|
||||
nameObject: "object",
|
||||
nameMixed: "mixed",
|
||||
nameNever: "never",
|
||||
nameTrue: "true",
|
||||
nameFalse: "false",
|
||||
nameNull: "null",
|
||||
}
|
||||
|
||||
nsResolver := nsresolver.NewNamespaceResolver()
|
||||
|
Loading…
Reference in New Issue
Block a user