Skip to content

Implement PHPStan extensions to reduce need for asserts #30

@dpi

Description

@dpi

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions