File: php80_named_params.phpt

package info (click to toggle)
php-ast 1.1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 632 kB
  • sloc: ansic: 2,173; xml: 621; php: 319; makefile: 2
file content (52 lines) | stat: -rw-r--r-- 1,235 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--TEST--
Named parameters in PHP 8.0
--SKIPIF--
<?php if (PHP_VERSION_ID < 80000) die('skip PHP >= 8.0 only'); ?>
--FILE--
<?php

require __DIR__ . '/../util.php';

$code = <<<'PHP'
<?php
$foo(first: 1, second: 2);
count(var: $argv);
$other->count(1, myVar:$foo, myVar: 1);  // error
PHP;

$node = ast\parse_code($code, $version=70);
echo ast_dump($node), "\n";
--EXPECTF--
AST_STMT_LIST
    0: AST_CALL
        expr: AST_VAR
            name: "foo"
        args: AST_ARG_LIST
            0: AST_NAMED_ARG
                name: "first"
                expr: 1
            1: AST_NAMED_ARG
                name: "second"
                expr: 2
    1: AST_CALL
        expr: AST_NAME
            flags: NAME_NOT_FQ (%d)
            name: "count"
        args: AST_ARG_LIST
            0: AST_NAMED_ARG
                name: "var"
                expr: AST_VAR
                    name: "argv"
    2: AST_METHOD_CALL
        expr: AST_VAR
            name: "other"
        method: "count"
        args: AST_ARG_LIST
            0: 1
            1: AST_NAMED_ARG
                name: "myVar"
                expr: AST_VAR
                    name: "foo"
            2: AST_NAMED_ARG
                name: "myVar"
                expr: 1