PHP

PHP

Made by DeepSource

Empty function/method found PHP-W1080

Anti-pattern
Major

An empty function or method is considered as dead code, and removing it from the codebase wouldn't make any difference to the application's logic. This might even confuse the developer in the future, questioning the existence and use of the code block. If the code block is not necessary, it is highly recommended it remove it. This would also improve the code readability.

In case it is left empty intentionally, or you are planning to implement it in the future, please consider adding a comment stating the reason why it has been left empty. DeepSource won't raise an issue if there's a comment for the empty function/method.

Bad practice

class User
{
    public function handle() {}
}

Recommended

Add a comment saying why it is kept empty:

class User
{
    public function handle()
    {
        // todo implement this
    }
}

Or else you can add comment above the method:

class User
{
    /**
     * TODO: Implement this.
     */
    public function handle()
    {
    }
}