xref: /php-ast/tests/php80_named_params.phpt (revision c6cc7b1c)
1--TEST--
2Named parameters in PHP 8.0
3--SKIPIF--
4<?php if (PHP_VERSION_ID < 80000) die('skip PHP >= 8.0 only'); ?>
5--FILE--
6<?php
7
8require __DIR__ . '/../util.php';
9
10$code = <<<'PHP'
11<?php
12$foo(first: 1, second: 2);
13count(var: $argv);
14$other->count(1, myVar:$foo, myVar: 1);  // error
15PHP;
16
17$node = ast\parse_code($code, $version=70);
18echo ast_dump($node), "\n";
19--EXPECTF--
20AST_STMT_LIST
21    0: AST_CALL
22        expr: AST_VAR
23            name: "foo"
24        args: AST_ARG_LIST
25            0: AST_NAMED_ARG
26                name: "first"
27                expr: 1
28            1: AST_NAMED_ARG
29                name: "second"
30                expr: 2
31    1: AST_CALL
32        expr: AST_NAME
33            flags: NAME_NOT_FQ (%d)
34            name: "count"
35        args: AST_ARG_LIST
36            0: AST_NAMED_ARG
37                name: "var"
38                expr: AST_VAR
39                    name: "argv"
40    2: AST_METHOD_CALL
41        expr: AST_VAR
42            name: "other"
43        method: "count"
44        args: AST_ARG_LIST
45            0: 1
46            1: AST_NAMED_ARG
47                name: "myVar"
48                expr: AST_VAR
49                    name: "foo"
50            2: AST_NAMED_ARG
51                name: "myVar"
52                expr: 1
53