MCPcopy Create free account
hub / github.com/z7zmey/php-parser / TestPrinterPrintExprClosure

Function TestPrinterPrintExprClosure

printer/printer_test.go:1705–1747  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1703}
1704
1705func TestPrinterPrintExprClosure(t *testing.T) {
1706 o := bytes.NewBufferString("")
1707
1708 p := printer.NewPrinter(o)
1709 p.Print(&expr.Closure{
1710 Static: true,
1711 ReturnsRef: true,
1712 Params: []node.Node{
1713 &node.Parameter{
1714 ByRef: true,
1715 Variadic: false,
1716 Variable: &expr.Variable{
1717 VarName: &node.Identifier{Value: "var"},
1718 },
1719 },
1720 },
1721 ClosureUse: &expr.ClosureUse{
1722 Uses: []node.Node{
1723 &expr.Reference{Variable: &expr.Variable{
1724 VarName: &node.Identifier{Value: "a"},
1725 }},
1726 &expr.Variable{
1727 VarName: &node.Identifier{Value: "b"},
1728 },
1729 },
1730 },
1731 ReturnType: &name.FullyQualified{
1732 Parts: []node.Node{&name.NamePart{Value: "Foo"}},
1733 },
1734 Stmts: []node.Node{
1735 &stmt.Expression{Expr: &expr.Variable{
1736 VarName: &node.Identifier{Value: "a"},
1737 }},
1738 },
1739 })
1740
1741 expected := `static function&(&$var)use(&$a,$b):\Foo{$a;}`
1742 actual := o.String()
1743
1744 if expected != actual {
1745 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
1746 }
1747}
1748
1749func TestPrinterPrintExprArrowFunction(t *testing.T) {
1750 o := bytes.NewBufferString("")

Callers

nothing calls this directly

Calls 3

PrintMethod · 0.95
NewPrinterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…