PHP

PHP

Made by DeepSource

Unused private class method found PHP-W1076

Anti-pattern
Minor
Autofix

The class contains unused private methods. These private class methods are dead code, and do nothing. It is recommended to remove these unused private methods.

It is also recommended that you review these unused private methods if they were added for later use in the code, but the author missed using them.

Bad practice

class User
{
    public function getName(): string
    {
        return 'John';
    }

    // invalid: setMessage() method is never unused
    private function setMessage(string $name): void
    {
        $this->name = $name;
    }
}

Recommended

Make sure to remove private methods that are not used:

class User
{
    public function getName(): string
    {
        return 'John';
    }
}

References