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

Function TestRefFunction

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

Source from the content-addressed store, hash-verified

261}
262
263func TestRefFunction(t *testing.T) {
264 src := `<? function &foo() {return 1;}`
265
266 expected := &node.Root{
267 Position: &position.Position{
268 StartLine: 1,
269 EndLine: 1,
270 StartPos: 3,
271 EndPos: 30,
272 },
273 Stmts: []node.Node{
274 &stmt.Function{
275 Position: &position.Position{
276 StartLine: 1,
277 EndLine: 1,
278 StartPos: 3,
279 EndPos: 30,
280 },
281 ReturnsRef: true,
282 PhpDocComment: "",
283 FunctionName: &node.Identifier{
284 Position: &position.Position{
285 StartLine: 1,
286 EndLine: 1,
287 StartPos: 13,
288 EndPos: 16,
289 },
290 Value: "foo",
291 },
292 Stmts: []node.Node{
293 &stmt.Return{
294 Position: &position.Position{
295 StartLine: 1,
296 EndLine: 1,
297 StartPos: 20,
298 EndPos: 29,
299 },
300 Expr: &scalar.Lnumber{
301 Position: &position.Position{
302 StartLine: 1,
303 EndLine: 1,
304 StartPos: 27,
305 EndPos: 28,
306 },
307 Value: "1",
308 },
309 },
310 },
311 },
312 },
313 }
314
315 php7parser := php7.NewParser([]byte(src), "7.4")
316 php7parser.Parse()
317 actual := php7parser.GetRootNode()
318 assert.DeepEqual(t, expected, actual)
319
320 php5parser := php5.NewParser([]byte(src), "5.6")

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…