An annoyance with complying with PHPStan is needing to use asserts, as in what is presently mentioned in Usage.
assert($reflector->forType(SomeClass::class) instanceof ClassReflection);
assert($reflector->forType(SomeEnum::class) instanceof EnumReflection);
assert($reflector->forType(SomeInterface::class) instanceof InterfaceReflection);
assert($reflector->forType(SomeTrait::class) instanceof TraitReflection);
An ideal way to get around for the need for this is to implement PHPstan extension which adds intelligence, much like https://github.com/phpstan/phpstan-mockery , https://github.com/phpstan/phpstan-phpunit etc.
In the above examples, it should be quite simple to tell in PHPStan that the arg passed to forType is a specific type, and thusly will return a specific XReflection instance.
Consider implementing a good-php/phpstan-reflection, or similar?
An annoyance with complying with PHPStan is needing to use asserts, as in what is presently mentioned in Usage.
An ideal way to get around for the need for this is to implement PHPstan extension which adds intelligence, much like https://github.com/phpstan/phpstan-mockery , https://github.com/phpstan/phpstan-phpunit etc.
In the above examples, it should be quite simple to tell in PHPStan that the arg passed to
forTypeis a specific type, and thusly will return a specificXReflectioninstance.Consider implementing a
good-php/phpstan-reflection, or similar?