1--TEST--
2Dynamic property support in php 8.2+
3--SKIPIF--
4<?php if (PHP_VERSION_ID < 80200) die('skip PHP >=8.2 only'); ?>
5--FILE--
6<?php
7error_reporting(E_ALL);
8ini_set('display_errors', 'stderr');
9
10function dump($x) {
11    var_export($x);
12    echo "\n";
13}
14
15function dump_attributes(string $class) {
16    echo "Attributes of $class:\n";
17    foreach ((new ReflectionClass($class))->getAttributes() as $attribute) {
18        echo "- " . $attribute->getName() . "\n";
19    }
20}
21
22$node = new ast\Node();
23$node->undeclaredDynamic = 123;
24dump($node);
25$metadata = new ast\Metadata();
26$metadata->undeclaredDynamic = 123;
27dump($metadata);
28dump_attributes(ast\Node::class);
29dump_attributes(ast\Metadata::class);
30--EXPECTF--
31%Sast\Node::__set_state(array(
32   'kind' => NULL,
33   'flags' => NULL,
34   'lineno' => NULL,
35   'children' => NULL,
36   'undeclaredDynamic' => 123,
37))
38Deprecated: Creation of dynamic property ast\Metadata::$undeclaredDynamic is deprecated in %sphp82_dynamic_property_attribute.php on line 21
39%Sast\Metadata::__set_state(array(
40   'kind' => NULL,
41   'name' => NULL,
42   'flags' => NULL,
43   'flagsCombinable' => NULL,
44   'undeclaredDynamic' => 123,
45))
46Attributes of ast\Node:
47- AllowDynamicProperties
48Attributes of ast\Metadata:
49