Arbit - project tracking

PHPMD

#7: UnusedLocalVariable ruleset incorrectly flags variables as unused when used inside double quoted string

Issue revisions

  • new by Joshua Ross at 2010-J-15 21:15
  • assigned by mapi at 2010-J-15 22:14
  • assigned by mapi at 2010-J-15 22:21
  • assigned by mapi at 2010-J-26 21:21
  • closed by mapi at 2010-F-24 11:48
Type bug bug
State closed closed
Priority low low
Resolution fixed fixed
Assigned to mapi
Scheduled for 0.2.3
Affected versions 0.2.0, 0.2.1, 0.2.x-svn
Affected components RuleSets / UnusedCode
Last change Wednesday 24 February 2010 11:48:38 UTC by mapi

Short description

The UnusedLocalVariable ruleset is incorrectly marking several variables as unused. These variables are being used inside double quoted strings. Here is an example

$usedVar = "foobar";

echo "Testing {$usedVar} inside a double quoted string";



Environment

PHP 5.2.10 RHEL 4.6

Steps to reproduce

Run the UnusedLocalVariable ruleset against a file with the following code:

::

$usedVar = "foobar";

echo "Testing {$usedVar} inside a double quoted string";

Expected behavior

No ruleset violations

Actual behavior

Unused local variable violation

  • mapi at Friday 15 January 2010 22:21:14 UTC

    This is caused by an issue in PHP_Depend's AST implemention. I have filed a ticket for this issue.

  • mapi at Tuesday 26 January 2010 21:21:05 UTC

    Rescheduled for version 0.2.3

  • shimik at Thursday 4 February 2010 14:41:33 UTC

    same thing with UnusedFormalParameter

  • Joshua Ross at Monday 15 February 2010 21:47:12 UTC

    just updating the link to the php_depend ticket, the one linked was to the edit page :)

    http://tracker.pdepend.org/pdepend/issue_tracker/issue/111

  • mapi at Wednesday 24 February 2010 11:48:38 UTC

    Fixed in svn revision #187.