sandhje / vscode-phpmd

VSCode PHP Mess Detector extension
MIT License
15 stars 3 forks source link

Got error for exit expression despite using best practice #64

Closed sinasaeedi closed 2 years ago

sinasaeedi commented 3 years ago

Hello there,

This is my code and I get this error: The method redirect() contains an exit expression.

public function redirect(string $redirectTo)
{
    if (wp_safe_redirect($redirectTo, 303)) {
        exit(1);
    }
}

What should I do to make this right?

sandhje commented 2 years ago

I believe this is a result of the following PHPMD rule: https://phpmd.org/rules/design.html.

I can't help you in what the best solution would be for your particular use case. My extension only shows the output of PHPMD as vscode diagnostics (the curly underline in your editor), for advice about an error you can contact to the authors of PHPMD or post a question on e.g. stack overflow.