File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
reference/reflection/reflectionparameter Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ function fruitBasket(
57
57
) { }
58
58
59
59
$reflection = new ReflectionFunction('fruitBasket');
60
- $parameter = $reflection->getParameter('apple') ;
60
+ $parameter = $reflection->getParameters()[0] ;
61
61
$attributes = $parameter->getAttributes();
62
62
print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
63
63
?>
@@ -96,7 +96,7 @@ function fruitBasket(
96
96
) { }
97
97
98
98
$reflection = new ReflectionFunction('fruitBasket');
99
- $parameter = $reflection->getParameter('apple') ;
99
+ $parameter = $reflection->getParameters()[0] ;
100
100
$attributes = $parameter->getAttributes('Fruit');
101
101
print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
102
102
?>
@@ -126,14 +126,18 @@ interface Color {
126
126
class Fruit {
127
127
}
128
128
129
+ #[Attribute]
130
+ class Red implements Color {
131
+ }
132
+
129
133
function fruitBasket(
130
134
#[Fruit]
131
135
#[Red]
132
136
string $apple
133
137
) { }
134
138
135
139
$reflection = new ReflectionFunction('fruitBasket');
136
- $parameter = $reflection->getParameter('apple') ;
140
+ $parameter = $reflection->getParameters()[0] ;
137
141
$attributes = $parameter->getAttributes('Color', ReflectionAttribute::IS_INSTANCEOF);
138
142
print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
139
143
?>
You can’t perform that action at this time.
0 commit comments