php8.1: added intersection types support (#29)
This commit is contained in:
@@ -180,6 +180,10 @@ func (p *printer) Union(n *ast.Union) {
|
||||
p.printSeparatedList(n.Types, n.SeparatorTkns, []byte("|"))
|
||||
}
|
||||
|
||||
func (p *printer) Intersection(n *ast.Intersection) {
|
||||
p.printSeparatedList(n.Types, n.SeparatorTkns, []byte("&"))
|
||||
}
|
||||
|
||||
func (p *printer) Attribute(n *ast.Attribute) {
|
||||
p.printNode(n.Name)
|
||||
p.printToken(n.OpenParenthesisTkn, p.ifNodeList(n.Args, []byte("(")))
|
||||
|
||||
@@ -104,3 +104,13 @@ $foo = $closure->__invoke(...);
|
||||
// new Foo(...); // not working
|
||||
`)
|
||||
}
|
||||
|
||||
func TestIntersectionTypesSyntaxPHP81(t *testing.T) {
|
||||
tester.NewParserPrintTestSuite(t).UsePHP8().Run(`<?php
|
||||
class Test {
|
||||
public A&B $prop;
|
||||
}
|
||||
|
||||
function test(A&B $a): A&B {}
|
||||
`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user