Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnusedLocalVariable doesn't detect unused var when defined twice #540

Closed
bkdotcom opened this issue Dec 27, 2017 · 2 comments · Fixed by #794
Closed

UnusedLocalVariable doesn't detect unused var when defined twice #540

bkdotcom opened this issue Dec 27, 2017 · 2 comments · Fixed by #794
Assignees
Labels

Comments

@bkdotcom
Copy link

function testUnused()
{
    $worthlessVar = false;
    $worthlessVar = true;
}

phpmd fails to raise any UnusedLocalVariable notice re $worthlessVar

@tvbeek tvbeek added the Bug label Sep 24, 2019
@kylekatarnls kylekatarnls self-assigned this May 21, 2020
@kylekatarnls kylekatarnls changed the title UnusedLocalVariable doesn't detect unused var UnusedLocalVariable doesn't detect unused var when defined twice May 21, 2020
@kylekatarnls
Copy link
Member

The following:

function testUnused()
{
    $worthlessVar = false;
}

did trigger the UnusedLocalVariable so it's actually the second assignation which is seen as a usage.

@bkdotcom
Copy link
Author

Excellent!

@ravage84 ravage84 added this to the 2.x (unspecific) milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

4 participants