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(
5757) { }
5858
5959$reflection = new ReflectionFunction('fruitBasket');
60- $parameter = $reflection->getParameter('apple') ;
60+ $parameter = $reflection->getParameters()[0] ;
6161$attributes = $parameter->getAttributes();
6262print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
6363?>
@@ -96,7 +96,7 @@ function fruitBasket(
9696) { }
9797
9898$reflection = new ReflectionFunction('fruitBasket');
99- $parameter = $reflection->getParameter('apple') ;
99+ $parameter = $reflection->getParameters()[0] ;
100100$attributes = $parameter->getAttributes('Fruit');
101101print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
102102?>
@@ -126,14 +126,18 @@ interface Color {
126126class Fruit {
127127}
128128
129+ #[Attribute]
130+ class Red implements Color {
131+ }
132+
129133function fruitBasket(
130134 #[Fruit]
131135 #[Red]
132136 string $apple
133137) { }
134138
135139$reflection = new ReflectionFunction('fruitBasket');
136- $parameter = $reflection->getParameter('apple') ;
140+ $parameter = $reflection->getParameters()[0] ;
137141$attributes = $parameter->getAttributes('Color', ReflectionAttribute::IS_INSTANCEOF);
138142print_r(array_map(fn($attribute) => $attribute->getName(), $attributes));
139143?>
You can’t perform that action at this time.
0 commit comments