Skip to content

Missing type check on array if another item is the correct type #11534

Closed
phpstan/phpstan-src
#5050

Description

@momala454

Bug report

If I check that one item of the array is the correct type, phpstan does not report that I mayt use another item with invalidtype

Code snippet that reproduces the problem

https://phpstan.org/r/f055c49c-c098-4328-be28-859fac2ebe9a

Expected output

Parameter #2 $param2 of function hello expects int, mixed given.

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

No response

Activity

  1. ondrejmirtes commented on Aug 19, 2024

    @ondrejmirtes
    Member

    Try turning on checkImplicitMixed

  2. momala454 commented on Aug 19, 2024

    @momala454
    Author

    with checkImplicitMixed true it gives the error

  3. phpstan-bot commented on Feb 26, 2026

    @phpstan-bot
    Contributor

    @momala454 After the latest push in 2.2.x, PHPStan now reports different result with your code snippet:

    @@ @@
    -No errors
    +12: Parameter #2 $param2 of function hello expects int, mixed given.
    Full report
    Line Error
    12 Parameter #2 $param2 of function hello expects int, mixed given.
  4. phpstan-bot commented on Feb 26, 2026

    @phpstan-bot
    Contributor

    Closed via merging phpstan/phpstan-src#5050

  5. github-actions commented on Mar 30, 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.

  6. locked as resolved and limited conversation to collaborators on Mar 30, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions