1--TEST--
2Attributes comply with inheritance rules.
3--FILE--
4<?php
5
6#[A2]
7class C1
8{
9    #[A1]
10    public function foo() { }
11}
12
13class C2 extends C1
14{
15    public function foo() { }
16}
17
18class C3 extends C1
19{
20    #[A1]
21    public function bar() { }
22}
23
24$ref = new \ReflectionClass(C1::class);
25print_r(array_map(fn ($a) => $a->getName(), $ref->getAttributes()));
26print_r(array_map(fn ($a) => $a->getName(), $ref->getMethod('foo')->getAttributes()));
27
28$ref = new \ReflectionClass(C2::class);
29print_r(array_map(fn ($a) => $a->getName(), $ref->getAttributes()));
30print_r(array_map(fn ($a) => $a->getName(), $ref->getMethod('foo')->getAttributes()));
31
32$ref = new \ReflectionClass(C3::class);
33print_r(array_map(fn ($a) => $a->getName(), $ref->getAttributes()));
34print_r(array_map(fn ($a) => $a->getName(), $ref->getMethod('foo')->getAttributes()));
35
36echo "\n";
37
38trait T1
39{
40    #[A2]
41    public $a;
42}
43
44class C4
45{
46    use T1;
47}
48
49class C5
50{
51    use T1;
52
53    public $a;
54}
55
56$ref = new \ReflectionClass(T1::class);
57print_r(array_map(fn ($a) => $a->getName(), $ref->getProperty('a')->getAttributes()));
58
59$ref = new \ReflectionClass(C4::class);
60print_r(array_map(fn ($a) => $a->getName(), $ref->getProperty('a')->getAttributes()));
61
62$ref = new \ReflectionClass(C5::class);
63print_r(array_map(fn ($a) => $a->getName(), $ref->getProperty('a')->getAttributes()));
64
65?>
66--EXPECT--
67Array
68(
69    [0] => A2
70)
71Array
72(
73    [0] => A1
74)
75Array
76(
77)
78Array
79(
80)
81Array
82(
83)
84Array
85(
86    [0] => A1
87)
88
89Array
90(
91    [0] => A2
92)
93Array
94(
95    [0] => A2
96)
97Array
98(
99)
100