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
|
case "mixed": // 8.0
|
||||||
fallthrough
|
fallthrough
|
||||||
case "never": // 8.1
|
case "never": // 8.1
|
||||||
|
fallthrough
|
||||||
|
case "true", "false", "null": // 8.2
|
||||||
return part, nil
|
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{
|
function := &ast.StmtFunction{
|
||||||
Name: &ast.Identifier{Value: []byte("bar")},
|
Name: &ast.Identifier{Value: []byte("bar")},
|
||||||
Params: []ast.Vertex{
|
Params: []ast.Vertex{
|
||||||
@ -924,6 +942,24 @@ func TestDoNotResolveReservedNames(t *testing.T) {
|
|||||||
Name: &ast.Identifier{Value: []byte("Never")},
|
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",
|
nameObject: "object",
|
||||||
nameMixed: "mixed",
|
nameMixed: "mixed",
|
||||||
nameNever: "never",
|
nameNever: "never",
|
||||||
|
nameTrue: "true",
|
||||||
|
nameFalse: "false",
|
||||||
|
nameNull: "null",
|
||||||
}
|
}
|
||||||
|
|
||||||
nsResolver := nsresolver.NewNamespaceResolver()
|
nsResolver := nsresolver.NewNamespaceResolver()
|
||||||
|
Loading…
Reference in New Issue
Block a user