Skip to content

Calling Closure(never): something not considered as an error #6485

@dktapps

Description

@dktapps

Bug report

I ran into this today while writing yet another event system.

In order to fully describe the type of the closure array $serializers in the following code, I resorted to using never, since that allows inserting a closure with parameter of any type. This allows me to still specify the return type of the closures in $serializers without having to just completely silence PHPStan.

In theory, it should also disallow it from being called, since a never type cannot be satisfied; however, passing something to a never argument is not reported as an error.

In practice, I would use a @phpstan-var to typecast the closure to the appropriate Closure(TBlockType): CompoundTag based on the indexing.

Code snippet that reproduces the problem

https://phpstan.org/r/644bfb47-682d-4a99-ba0e-be0c03cee6db

Expected result

An error should be emitted on line 32, since I'm passing Block to a type of never, which is illegal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions