xref: /php-ast/tests/constructor.phpt (revision a04f661f)
1--TEST--
2ast\Node has a __construct method
3--FILE--
4<?php
5
6require __DIR__ . '/../util.php';
7error_reporting(E_ALL);
8
9// Parameters are optional
10var_dump(new \ast\Node());
11
12// Check that null can be passed to any nullable param
13// ?int $kind, ?int $flags, ?array $children, ?int $lineno, ?int $endLineno]
14var_dump(new \ast\Node(null, null, null, null));
15
16// `FOO`
17echo ast_dump(new \ast\Node(\ast\AST_NAME, 1, ['name' => 'FOO'], 2), AST_DUMP_LINENOS) . "\n";
18
19?>
20===DONE===
21--EXPECT--
22object(ast\Node)#1 (4) {
23  ["kind"]=>
24  NULL
25  ["flags"]=>
26  NULL
27  ["lineno"]=>
28  NULL
29  ["children"]=>
30  NULL
31}
32object(ast\Node)#1 (4) {
33  ["kind"]=>
34  NULL
35  ["flags"]=>
36  NULL
37  ["lineno"]=>
38  NULL
39  ["children"]=>
40  NULL
41}
42AST_NAME @ 2
43    flags: NAME_NOT_FQ (1)
44    name: "FOO"
45===DONE===
46