phpstorm-attributes
phpstorm-attributes copied to clipboard
Impossible to read properties from `#[ExpectedValues]`
Our codebase is annotated with #[ExpectedValues] and for a custom analyzer I want to read some of these but that's not possible.
https://github.com/JetBrains/phpstorm-attributes/blob/411f40e9d39088e16a0475d00cc91931315120fa/src/ExpectedValues.php#L40
Please change the attributes so that the variables are public readonly or add getters so that the values can be retrieved.
There's another way how to get the values
foreach ($reflection->getParameters() as $parameter) {
foreach ($parameter->getAttributes(ExpectedValues::class) as $attribute) {
$arguments = $attribute->getArguments();
$values = $arguments[0] ?? $arguments['values'] ?? [];
$flags = $arguments[1] ?? $arguments['flags'] ?? [];
// etc.
}
}