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

Function TestArrowFunction

node/expr/t_arrow_function_test.go:15–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestArrowFunction(t *testing.T) {
16 src := `<? fn() => $a;`
17
18 expected := &node.Root{
19 Position: &position.Position{
20 StartLine: 1,
21 EndLine: 1,
22 StartPos: 3,
23 EndPos: 14,
24 },
25 Stmts: []node.Node{
26 &stmt.Expression{
27 Position: &position.Position{
28 StartLine: 1,
29 EndLine: 1,
30 StartPos: 3,
31 EndPos: 14,
32 },
33 Expr: &expr.ArrowFunction{
34 Position: &position.Position{
35 StartLine: 1,
36 EndLine: 1,
37 StartPos: 3,
38 EndPos: 13,
39 },
40 ReturnsRef: false,
41 Static: false,
42 PhpDocComment: "",
43 Expr: &expr.Variable{
44 Position: &position.Position{
45 StartLine: 1,
46 EndLine: 1,
47 StartPos: 11,
48 EndPos: 13,
49 },
50 VarName: &node.Identifier{
51 Position: &position.Position{
52 StartLine: 1,
53 EndLine: 1,
54 StartPos: 11,
55 EndPos: 13,
56 },
57 Value: "a",
58 },
59 },
60 },
61 },
62 },
63 }
64
65 php7parser := php7.NewParser([]byte(src), "7.4")
66 php7parser.Parse()
67 actual := php7parser.GetRootNode()
68 assert.DeepEqual(t, expected, actual)
69}
70
71func TestArrowFunctionReturnType(t *testing.T) {
72 src := `<? fn & () : foo => $a;`

Callers

nothing calls this directly

Calls 3

ParseMethod · 0.95
GetRootNodeMethod · 0.95
NewParserFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…