Skip to content

Covariance: Error reported on L6, but not L10 #13876

Closed

Description

@Csardelacal

Bug report

When analyzing this code with l3, l4, l5, l6, or l7:
https://phpstan.org/r/890b1916-744c-4f2e-9db8-1cf430e8d583

I get the following error:
Property B::$b (Trap<int|null, A|null>) does not accept Trap<int|null, A|null>.

This error does not appear in l8, l9 or l10.

Code snippet that reproduces the problem

https://phpstan.org/r/890b1916-744c-4f2e-9db8-1cf430e8d583

Expected output

I assume this should pass without issue, just like in the higher levels.

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

Yes, PHPStan is an essential tool for me to keep track of how our legacy project is evolving and getting modernized.

Activity

  1. added theissue type on Dec 3, 2025
  2. removed theissue type on Dec 3, 2025
  3. added this to the Generics milestone on Dec 3, 2025
  4. VincentLanglet commented on Dec 12, 2025

    @VincentLanglet
    Contributor

    Same issue than #9096

  5. phpstan-bot commented on Sep 10, 2026

    @phpstan-bot
    Contributor

    Closed via merging phpstan/phpstan-src#6392

  6. github-actions commented on Oct 12, 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.

  7. locked as resolved and limited conversation to collaborators on Oct 12, 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