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

Function TestPrinterPrintStmtFunction

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

Source from the content-addressed store, hash-verified

3607}
3608
3609func TestPrinterPrintStmtFunction(t *testing.T) {
3610 o := bytes.NewBufferString("")
3611
3612 p := printer.NewPrinter(o)
3613 p.Print(&stmt.Function{
3614 ReturnsRef: true,
3615 FunctionName: &node.Identifier{Value: "foo"},
3616 Params: []node.Node{
3617 &node.Parameter{
3618 ByRef: true,
3619 Variadic: false,
3620 Variable: &expr.Variable{
3621 VarName: &node.Identifier{Value: "var"},
3622 },
3623 },
3624 },
3625 ReturnType: &name.FullyQualified{
3626 Parts: []node.Node{&name.NamePart{Value: "Foo"}},
3627 },
3628 Stmts: []node.Node{
3629 &stmt.Nop{},
3630 },
3631 })
3632
3633 expected := `function &foo(&$var):\Foo{;}`
3634 actual := o.String()
3635
3636 if expected != actual {
3637 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3638 }
3639}
3640
3641func TestPrinterPrintStmtGlobal(t *testing.T) {
3642 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…