On the case of a private property from a parent class, PhpStanExtractor can't get types from the property evenbt though a comment on the getDocBlackFromProperty says // Use a ReflectionProperty instead of $class to get the parent class if applicable
The line $reflectionProperty = new \ReflectionProperty($class, $property); will trhow an Exception saying the property doesn't exists and the method will simply return null
Looking at the code on 7.2 branch this should allso happen in 7.2.
How to reproduce
3v4l reproducer about the ReflectionProperty throwing an exception : https://3v4l.org/MtHKU
If needed i'll make a reproducer repo as soon as I can
Possible Solution
On the catch:
make a $reflectionClass = new ReflectionClass($class);
re-call getDocBlockFromProperty with the parent class : $this->getDocBlockFromProperty($reflectionClass->getParentClass()->getName());
Though it's adding Reflection call so maybe it was intended to not do that from the start for performance ?
Symfony version(s) affected
6.4.9
Description
On the case of a private property from a parent class,
PhpStanExtractor
can't get types from the property evenbt though a comment on thegetDocBlackFromProperty
says// Use a ReflectionProperty instead of $class to get the parent class if applicable
The line
$reflectionProperty = new \ReflectionProperty($class, $property);
will trhow an Exception saying the property doesn't exists and the method will simply return nullLooking at the code on 7.2 branch this should allso happen in 7.2.
How to reproduce
3v4l reproducer about the
ReflectionProperty
throwing an exception : https://3v4l.org/MtHKUIf needed i'll make a reproducer repo as soon as I can
Possible Solution
On the catch:
$reflectionClass = new ReflectionClass($class);
getDocBlockFromProperty
with the parent class :$this->getDocBlockFromProperty($reflectionClass->getParentClass()->getName());
Though it's adding Reflection call so maybe it was intended to not do that from the start for performance ?
Additional Context
No response