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

Function TestPrintStmtAbstractClassMethod

printer/pretty_printer_test.go:2489–2519  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2487 }
2488}
2489func TestPrintStmtAbstractClassMethod(t *testing.T) {
2490 o := bytes.NewBufferString("")
2491
2492 p := printer.NewPrettyPrinter(o, " ")
2493 p.Print(&stmt.ClassMethod{
2494 Modifiers: []node.Node{&node.Identifier{Value: "public"}},
2495 ReturnsRef: true,
2496 MethodName: &node.Identifier{Value: "foo"},
2497 Params: []node.Node{
2498 &node.Parameter{
2499 ByRef: true,
2500 VariableType: &node.Nullable{Expr: &name.Name{Parts: []node.Node{&name.NamePart{Value: "int"}}}},
2501 Variable: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
2502 DefaultValue: &expr.ConstFetch{Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "null"}}}},
2503 },
2504 &node.Parameter{
2505 Variadic: true,
2506 Variable: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
2507 },
2508 },
2509 ReturnType: &name.Name{Parts: []node.Node{&name.NamePart{Value: "void"}}},
2510 Stmt: &stmt.Nop{},
2511 })
2512
2513 expected := `public function &foo(?int &$a = null, ...$b): void;`
2514 actual := o.String()
2515
2516 if expected != actual {
2517 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2518 }
2519}
2520
2521func TestPrintStmtClass(t *testing.T) {
2522 o := bytes.NewBufferString("")

Callers

nothing calls this directly

Calls 3

PrintMethod · 0.95
NewPrettyPrinterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…