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

Function TestPrinterPrintStmtAbstractClassMethod

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

Source from the content-addressed store, hash-verified

2968}
2969
2970func TestPrinterPrintStmtAbstractClassMethod(t *testing.T) {
2971 o := bytes.NewBufferString("")
2972
2973 p := printer.NewPrinter(o)
2974 p.Print(&stmt.ClassMethod{
2975 Modifiers: []node.Node{
2976 &node.Identifier{Value: "public"},
2977 &node.Identifier{Value: "static"},
2978 },
2979 ReturnsRef: true,
2980 MethodName: &node.Identifier{Value: "foo"},
2981 Params: []node.Node{
2982 &node.Parameter{
2983 ByRef: true,
2984 VariableType: &node.Nullable{Expr: &name.Name{Parts: []node.Node{&name.NamePart{Value: "int"}}}},
2985 Variable: &expr.Variable{
2986 VarName: &node.Identifier{Value: "a"},
2987 },
2988 DefaultValue: &expr.ConstFetch{Constant: &name.Name{Parts: []node.Node{&name.NamePart{Value: "null"}}}},
2989 },
2990 &node.Parameter{
2991 Variadic: true,
2992 Variable: &expr.Variable{
2993 VarName: &node.Identifier{Value: "b"},
2994 },
2995 },
2996 },
2997 ReturnType: &name.Name{
2998 Parts: []node.Node{&name.NamePart{Value: "void"}},
2999 },
3000 Stmt: &stmt.Nop{},
3001 })
3002
3003 expected := `public static function &foo(?int&$a=null,...$b):void;`
3004 actual := o.String()
3005
3006 if expected != actual {
3007 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3008 }
3009}
3010
3011func TestPrinterPrintStmtClass(t *testing.T) {
3012 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…