PHPCheckstyle/phpcheckstyle

Ability to add exceptions to "unused variable" test

rr- opened this issue · 1 comments

rr- commented

Right now, I have code like this:

public function createSomething($userInput)
{
    try
    {
        $this->externalLibrary->createSomething($userInput);
    }
    catch (\Exception $e)
    {
        //I couldn't care less for the content of $e
        return null;
    }
}

There is no way to turn off notification about unused $e variable. I expected to be able to add <exception value="e"/> for <test name="checkUnusedVariables"/> just like I can do it for <test name="localScopeVariableLength"/>, but it doesn't seem to do anything.

Adding stuff like unset($e); works, but it makes the code ugly, while the point of using phpcheckstyle is to make it prettier.

Agreed - this could definitely be improved.