php8.1: added intersection types support (#29)

This commit is contained in:
Makhnev Petr
2022-06-26 03:31:29 +03:00
committed by GitHub
parent 7f6cd25376
commit e16671724e
21 changed files with 22940 additions and 22127 deletions

View File

@@ -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("(")))

View File

@@ -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 {}
`)
}