Skip to content

Types: Member::$roles #1431

Description

@liamduckett

Environment

  • PHP Version:
    • 8.4
  • DiscordPHP Version:
    • 10.29.6

Description
My static analyser (PHPStan) fails with the following code:

$member->roles->any(fn() => true)
Cannot call method any() on 
array<Discord\Parts\Guild\Role>|(Discord\Helpers\ExCollectionInterface&iterable<Discord\Parts\Guild\Role>).
🪪  method.nonObject

Expected behavior
No error - this method can only return ExCollectionInterface&iterable<Role> so the call to any is type safe.

Additional context
There was mention of the proposed fix (removing the impossible type) causing issues with most IDEs and even intelliphense. See: #1430.

Activity

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions