New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Psalm is unaware of a handful of methods on the various core reflection classes #7810
Comments
I found these snippets: https://psalm.dev/r/7de1ce446b<?php
class PropertyWrapper {
private ReflectionProperty $reflection;
public function __construct(ReflectionProperty $reflection)
{
$this->reflection = $reflection;
}
public function hasDefault(): bool
{
return $this->reflection->hasDefaultValue();
}
}
https://psalm.dev/r/0b4cc46fd2<?php
class PropertyWrapper {
private ReflectionProperty $reflection;
public function __construct(ReflectionProperty $reflection)
{
$this->reflection = $reflection;
}
public function isPromoted(): bool
{
return $this->reflection->isPromoted();
}
}
https://psalm.dev/r/62322a32a6<?php
class PropertyWrapper {
private ReflectionParameter $reflection;
public function __construct(ReflectionParameter $reflection)
{
$this->reflection = $reflection;
}
public function isPromoted(): bool
{
return $this->reflection->isPromoted();
}
}
|
It is also unaware of |
I found these snippets: https://psalm.dev/r/8f628693b7<?php
class AttributeWrapper {
private Attribute $attribute;
public function __construct(Attribute $attribute)
{
$this->attribute = $attribute;
}
public function getFlags(): int
{
return $this->attribute->flags;
}
public function isRepeatable(): bool
{
return (bool)($this->getFlags() & Attribute::IS_REPEATABLE);
}
}
|
Go for it! Just be sure to use the correct |
Sorry, this got buried under mountain if other things. If this still hasn't been fixed I will take a look and create a PR for the reflection stubs. |
I've only created examples for the ones that I encountered, but if my understanding is correct, and
stubs/Reflection.phpstub
is how Psalm understands reflection classes, there is a lot missing.ReflectionProperty::hasDefaultValue()
https://psalm.dev/r/7de1ce446bReflectionProperty::isPromoted()
https://psalm.dev/r/0b4cc46fd2ReflectionParameter::isPromoted()
https://psalm.dev/r/62322a32a6If my assumption/understanding is correct, I'm more than happy to create a PR that updates all of the Reflection stubs to accurately match what is available.
The text was updated successfully, but these errors were encountered: