Skip to content

Unable to resolve closure type inside an array #11215

Closed
phpstan/phpstan-src
#6422

Description

@calebdw

Bug report

Hello!

It looks like PHPStan is having issues resolving closure types that are inside an array:

/** @param array<string, (callable(Builder<TModel>): mixed)|string> $relations */

Please see the playground link for an example, but everything works fine if the closure is the only input to the method, but if I pass an array of closures then it has issues.

Thanks!

Code snippet that reproduces the problem

https://phpstan.org/r/3886e27b-edec-4c08-b776-968e0d7cee9a

Expected output

The assertType call should pass inside the loadMany method.

Did PHPStan help you today? Did it make you happy in any way?

Absolutely! It gives me the confidence to ship code to production 😄

Activity

  1. changed the title [-]Unable to resolve closure type inside an arry[/-] [+]Unable to resolve closure type inside an array[/+] on Jun 20, 2024
  2. added this to the Generics milestone on Jul 6, 2024
  3. github-actions commented on Oct 13, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  4. locked as resolved and limited conversation to collaborators on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions