summaryrefslogtreecommitdiff
path: root/Zend/tests/attributes/028_grouped.phpt
blob: 9796531bdaee5da33110b805ddfffda37f3452bb (plain)
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
53
54
55
--TEST--
Attributes can be grouped
--FILE--
<?php

#[A1(1), A1(2), A2(3)]
class Foo
{
}

#[
    A1(1),
    A1(2),
    A2(3)
]
function foo() {}

#[A1, A1, A2]
function bar() {}

$sources = [
    new \ReflectionClass(Foo::class),
    new \ReflectionFunction('foo'),
    new \ReflectionFunction('bar'),
];

foreach ($sources as $ref) {
    $attr = $ref->getAttributes();
    var_dump(get_class($ref), count($attr));

    foreach ($attr as $a) {
        printf("%s(%s)\n", $a->getName(), implode(", ", $a->getArguments()));
    }

    echo "\n";
}
?>
--EXPECT--
string(15) "ReflectionClass"
int(3)
A1(1)
A1(2)
A2(3)

string(18) "ReflectionFunction"
int(3)
A1(1)
A1(2)
A2(3)

string(18) "ReflectionFunction"
int(3)
A1()
A1()
A2()