|
1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | | -<!-- EN-Revision: fadab82e11cf93c08eb214cf9d67e9e5ac586a30 Maintainer: Fan2Shrek Status: ready --> |
| 2 | +<!-- EN-Revision: 54c9db669dc89cabc3fa9d5f75af088957e1fd2c Maintainer: Fan2Shrek Status: ready --> |
3 | 3 | <!-- Reviewed: yes --> |
4 | 4 | <refentry xml:id="reflectionparameter.getattributes" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> |
5 | 5 | <refnamediv> |
@@ -58,7 +58,7 @@ function fruitBasket( |
58 | 58 | ) { } |
59 | 59 |
|
60 | 60 | $reflection = new ReflectionFunction('fruitBasket'); |
61 | | -$parameter = $reflection->getParameter('apple'); |
| 61 | +$parameter = $reflection->getParameters()[0]; |
62 | 62 | $attributes = $parameter->getAttributes(); |
63 | 63 | print_r(array_map(fn($attribute) => $attribute->getName(), $attributes)); |
64 | 64 | ?> |
@@ -97,7 +97,7 @@ function fruitBasket( |
97 | 97 | ) { } |
98 | 98 |
|
99 | 99 | $reflection = new ReflectionFunction('fruitBasket'); |
100 | | -$parameter = $reflection->getParameter('apple'); |
| 100 | +$parameter = $reflection->getParameters()[0]; |
101 | 101 | $attributes = $parameter->getAttributes('Fruit'); |
102 | 102 | print_r(array_map(fn($attribute) => $attribute->getName(), $attributes)); |
103 | 103 | ?> |
@@ -127,14 +127,18 @@ interface Color { |
127 | 127 | class Fruit { |
128 | 128 | } |
129 | 129 |
|
| 130 | +#[Attribute] |
| 131 | +class Red implements Color { |
| 132 | +} |
| 133 | +
|
130 | 134 | function fruitBasket( |
131 | 135 | #[Fruit] |
132 | 136 | #[Red] |
133 | 137 | string $apple |
134 | 138 | ) { } |
135 | 139 |
|
136 | 140 | $reflection = new ReflectionFunction('fruitBasket'); |
137 | | -$parameter = $reflection->getParameter('apple'); |
| 141 | +$parameter = $reflection->getParameters()[0]; |
138 | 142 | $attributes = $parameter->getAttributes('Color', ReflectionAttribute::IS_INSTANCEOF); |
139 | 143 | print_r(array_map(fn($attribute) => $attribute->getName(), $attributes)); |
140 | 144 | ?> |
|
0 commit comments