php8.1: resolve intersection types in NamespaceResolver
This commit is contained in:
parent
3c45afd848
commit
6855357aaa
@ -283,6 +283,10 @@ func (nsr *NamespaceResolver) ResolveType(n ast.Vertex) {
|
||||
for _, nnn := range nn.Types {
|
||||
nsr.ResolveType(nnn)
|
||||
}
|
||||
case *ast.Intersection:
|
||||
for _, nnn := range nn.Types {
|
||||
nsr.ResolveType(nnn)
|
||||
}
|
||||
|
||||
case *ast.Name:
|
||||
nsr.ResolveName(n, "")
|
||||
|
@ -542,6 +542,8 @@ func TestResolveMethodName(t *testing.T) {
|
||||
nameBC := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("B")}, &ast.NamePart{Value: []byte("C")}}}
|
||||
nameCD := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("C")}, &ast.NamePart{Value: []byte("D")}}}
|
||||
nameDE := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("D")}, &ast.NamePart{Value: []byte("E")}}}
|
||||
nameEF := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("E")}, &ast.NamePart{Value: []byte("F")}}}
|
||||
nameFG := &ast.Name{Parts: []ast.Vertex{&ast.NamePart{Value: []byte("F")}, &ast.NamePart{Value: []byte("G")}}}
|
||||
|
||||
methodNode := &ast.StmtClassMethod{
|
||||
Name: &ast.Identifier{Value: []byte("A")},
|
||||
@ -554,6 +556,10 @@ func TestResolveMethodName(t *testing.T) {
|
||||
Type: &ast.Union{Types: []ast.Vertex{nameCD, nameDE}},
|
||||
Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("all")}},
|
||||
},
|
||||
&ast.Parameter{
|
||||
Type: &ast.Intersection{Types: []ast.Vertex{nameEF, nameFG}},
|
||||
Var: &ast.ExprVariable{Name: &ast.Identifier{Value: []byte("any")}},
|
||||
},
|
||||
},
|
||||
ReturnType: &ast.Nullable{Expr: nameBC},
|
||||
Stmt: &ast.StmtStmtList{
|
||||
@ -566,6 +572,8 @@ func TestResolveMethodName(t *testing.T) {
|
||||
nameBC: "B\\C",
|
||||
nameCD: "C\\D",
|
||||
nameDE: "D\\E",
|
||||
nameEF: "E\\F",
|
||||
nameFG: "F\\G",
|
||||
}
|
||||
|
||||
nsResolver := nsresolver.NewNamespaceResolver()
|
||||
|
Loading…
Reference in New Issue
Block a user