Skip to content

File-scope unused variable not detected when ?> is present #232

Closed
@GaryJones

Description

@GaryJones

Snippet 1:

<?php

$unused_variable = 'foo';

With the default configuration (phpcs --standard=VariableAnalysis -s phpcs-test.php), this is detected as "Unused variable $unused_variable (VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable)". ✅

Snippet 2:

<?php

$unused_variable = 'foo';
?>

The addition of the ?> stops the violation from being reported, even though the variable is still unused. ❌

Tested in VA 2.11.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions