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

Function TestSimpleFunction

node/stmt/t_function_test.go:19–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestSimpleFunction(t *testing.T) {
20 src := `<? function foo() {}`
21
22 expected := &node.Root{
23 Position: &position.Position{
24 StartLine: 1,
25 EndLine: 1,
26 StartPos: 3,
27 EndPos: 20,
28 },
29 Stmts: []node.Node{
30 &stmt.Function{
31 Position: &position.Position{
32 StartLine: 1,
33 EndLine: 1,
34 StartPos: 3,
35 EndPos: 20,
36 },
37 ReturnsRef: false,
38 PhpDocComment: "",
39 FunctionName: &node.Identifier{
40 Position: &position.Position{
41 StartLine: 1,
42 EndLine: 1,
43 StartPos: 12,
44 EndPos: 15,
45 },
46 Value: "foo",
47 },
48 Stmts: []node.Node{},
49 },
50 },
51 }
52
53 php7parser := php7.NewParser([]byte(src), "7.4")
54 php7parser.Parse()
55 actual := php7parser.GetRootNode()
56 assert.DeepEqual(t, expected, actual)
57
58 php5parser := php5.NewParser([]byte(src), "5.6")
59 php5parser.Parse()
60 actual = php5parser.GetRootNode()
61 assert.DeepEqual(t, expected, actual)
62}
63
64func TestFunctionReturn(t *testing.T) {
65 src := `<? function foo() {return;}`

Callers

nothing calls this directly

Calls 4

ParseMethod · 0.95
GetRootNodeMethod · 0.95
NewParserFunction · 0.92
NewParserFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…