Skip to content

Error „should return static(Test) but returns Test“ #4860

Closed

Description

@CsabaNa

Bug report

There is an issue with the same title #2885 but the bug still exist

Code snippet that reproduces the problem

I just created a small "copy" function to represent the problem
https://phpstan.org/r/fe9e1e02-3f64-4cad-bc89-988063530480

Expected output

no error

Activity

  1. added this to the Easy fixes milestone on Apr 15, 2021
  2. phpstan-bot commented on Oct 4, 2021

    @phpstan-bot
    Contributor

    @CsabaNa After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

    @@ @@
    - 7: Method Test::copy() should return static(Test) but returns Test.
    + 5: Method Test::copy() should return static(Test) but return statement is missing.
    +15: Method Test::copyTo() should return T but return statement is missing.
    Full report
    Line Error
    5 Method Test::copy() should return static(Test) but return statement is missing.
    15 Method Test::copyTo() should return T but return statement is missing.
  3. added a commit that references this issue on Mar 13, 2026
    dcdd6fa
  4. phpstan-bot commented on Mar 13, 2026

    @phpstan-bot
    Contributor

    Closed via merging phpstan/phpstan-src#5190

  5. added 2 commits that reference this issue on Mar 13, 2026
    dcdd6fa
    de44abd
  6. added a commit that references this issue on Apr 7, 2026
    096fb21
  7. github-actions commented on Apr 14, 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.

  8. locked as resolved and limited conversation to collaborators on Apr 14, 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