Skip to content

"method unused" when overriding private methode of a trait #12201

Closed
phpstan/phpstan-src
#6191

Description

@adpeyre

Bug report

I've an issue when I try to override a private method of the trait.

Method App\Twig\Components\Account\ChangePasswordForm::getDataModelValue() is unused.
        . method.unused

getDataModelValue is declared in the trait used by the ChangePasswordForm class.

Code snippet that reproduces the problem

https://phpstan.org/r/95681446-f065-468c-9eb4-7c3df1e8be28

Expected output

No error

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

ty PHPStan. You help me every day.

Activity

  1. adpeyre commented on Dec 6, 2024

    @adpeyre
    Author

    The simplified example works... I try to find the case which is an error.

    Maybe when the trait is in package outside the project (in vendor) ? Is it possible ?

  2. vjik commented on Jan 8, 2025

    @vjik

    I have same error.

    PHPStan don't analyse trait from vendor, so show method.unused error.

  3. added this to the Easy fixes milestone on Sep 12, 2025
  4. Asenar commented on Sep 29, 2025

    @Asenar

    Hi,

    The link in the result is marked as «no error» and «out of date», but the bug is still present

    Here a demo with a simplified usage we can do in Symfony: https://phpstan.org/r/531b373b-93e4-4728-90c4-137561203581

  5. added a commit that references this issue on Aug 13, 2026
    c718210
  6. added a commit that references this issue on Sep 28, 2026
    cc29965
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