forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgh20895.phpt
More file actions
108 lines (101 loc) · 2.93 KB
/
gh20895.phpt
File metadata and controls
108 lines (101 loc) · 2.93 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
--TEST--
GH-20895: ReflectionProperty does not return the PHPDoc of a property if it contains an attribute with a Closure
--FILE--
<?php
/** Foo */
#[Attr(
/** Closure 1 */
static function() { },
/** Closure 2 */
static function() { },
)]
class Foo {
/** Foo::$bar */
#[Attr(
/** Closure 3 */
static function() { },
/** Closure 4 */
static function() { },
)]
#[Attr(
/** Closure 5 */
static function() { },
)]
public $bar;
/** Foo::bar() */
#[Attr(
/** Closure 6 */
static function() { },
)]
public function bar() { }
}
/** foo() */
#[Attr(
/** Closure 7 */
static function() { },
)]
function foo() { }
#[Attr(
/** Closure 8 */
static function() { },
)]
/** bar() */
function bar() { }
/** baz() */
#[Attr(
static function() { },
)]
function baz() { }
var_dump((new ReflectionClass(Foo::class))->getDocComment());
foreach ((new ReflectionClass(Foo::class))->getAttributes() as $attribute) {
foreach ($attribute->getArguments() as $argument) {
var_dump((new ReflectionFunction($argument))->getDocComment());
}
}
var_dump((new ReflectionProperty(Foo::class, 'bar'))->getDocComment());
foreach ((new ReflectionProperty(Foo::class, 'bar'))->getAttributes() as $attribute) {
foreach ($attribute->getArguments() as $argument) {
var_dump((new ReflectionFunction($argument))->getDocComment());
}
}
var_dump((new ReflectionMethod(Foo::class, 'bar'))->getDocComment());
foreach ((new ReflectionMethod(Foo::class, 'bar'))->getAttributes() as $attribute) {
foreach ($attribute->getArguments() as $argument) {
var_dump((new ReflectionFunction($argument))->getDocComment());
}
}
var_dump((new ReflectionFunction('foo'))->getDocComment());
foreach ((new ReflectionFunction('foo'))->getAttributes() as $attribute) {
foreach ($attribute->getArguments() as $argument) {
var_dump((new ReflectionFunction($argument))->getDocComment());
}
}
var_dump((new ReflectionFunction('bar'))->getDocComment());
foreach ((new ReflectionFunction('bar'))->getAttributes() as $attribute) {
foreach ($attribute->getArguments() as $argument) {
var_dump((new ReflectionFunction($argument))->getDocComment());
}
}
var_dump((new ReflectionFunction('baz'))->getDocComment());
foreach ((new ReflectionFunction('baz'))->getAttributes() as $attribute) {
foreach ($attribute->getArguments() as $argument) {
var_dump((new ReflectionFunction($argument))->getDocComment());
}
}
?>
--EXPECT--
string(10) "/** Foo */"
string(16) "/** Closure 1 */"
string(16) "/** Closure 2 */"
string(16) "/** Foo::$bar */"
string(16) "/** Closure 3 */"
string(16) "/** Closure 4 */"
string(16) "/** Closure 5 */"
string(17) "/** Foo::bar() */"
string(16) "/** Closure 6 */"
string(12) "/** foo() */"
string(16) "/** Closure 7 */"
string(12) "/** bar() */"
string(16) "/** Closure 8 */"
string(12) "/** baz() */"
bool(false)