When i get the attributes of my function. If i getName()
, i’ve a path as name BaseServiceClientfilters
.. How i can only get filters
as name ?
#[filters(['email', 'emailVerified', 'enabled', 'firstName', 'lastName', 'q', 'username'])]
public function getUsers(?array $filter = null): iterable
{
$method = new ReflectionMethod($this, 'getUsers');
$attributes = $method->getAttributes();
$f = [];
foreach ($attributes as $reflection) {
$f[$reflection->getName()] = $reflection->getArguments();
}
dd($f);
OUPUT:
[
'BaseServiceClientfilters' => [ /** I'ld filter, like thats i can $method->getAttributes('filters)
(int) 0 => [
(int) 0 => 'email',
(int) 1 => 'emailVerified',
(int) 2 => 'enabled',
(int) 3 => 'firstName',
(int) 4 => 'lastName',
(int) 5 => 'q',
(int) 6 => 'username',
],
],
]
New contributor