Fetch properties from functions:
----------------------------------------
Function definition with attributes:
----------------------------------------
#[ReadOnly]
#[Property(type: 'function', name: 'Hello')]
function Hello()
{
return "Hello";
}
-----------------------------------------
Gather attributes from the function
-----------------------------------------
function getAttributes(Reflector $reflection)
{
$attributes = $reflection->getAttributes();
$result = [];
foreach ($attributes as $attribute)
{
$result[$attribute->getName()] = $attribute->getArguments();
}
return $result;
}
$reflection = new ReflectionFunction("Hello");
print_r(getAttributes($reflection));
-----------------------------
OUTPUT
-----------------------------
Array
(
[ReadOnly] => Array
(
)
[Property] => Array
(
[type] => function
[name] => Hello
)
)