Roave/BetterReflection

Not all public properties in Adapter namespace work correctly

ondrejmirtes opened this issue · 1 comments

There's currently an unset + __get hack for ReflectionClass::$name:

+
public function __get(string $name): mixed
{
if ($name === 'name') {
return $this->betterReflectionClass->getName();
}
throw new OutOfBoundsException(sprintf('Property %s::$%s does not exist.', self::class, $name));
}

We need to do a similar hack for other public properties. There's about 12 of them judging from https://github.com/JetBrains/phpstorm-stubs/tree/master/Reflection.

Otherwise we can get errors like Error: Typed property ReflectionParameter::$name must not be accessed before initialization.

Originally reported: phpstan/phpstan#7428

Urgh, public properties @_@