Page MenuHomePhabricator

Exclude variables used in strings inside closures when checking for undeclared variables
ClosedPublic

Authored by joshuaspence on Aug 19 2015, 9:23 AM.

Details

Summary

Improves upon D13795 to correctly handle variables within strings. Specifically, the following code currently (incorrectly) warns about $x being undeclared:

function some_func() {
  return function ($x) {
    echo "$x";
  };
}

It's worth noting that the situation would be improved if XHPAST properly parsed strings (see T8049).

Test Plan

Added test case.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joshuaspence retitled this revision from to Improvement to undeclared variable linter rule.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
joshuaspence edited edge metadata.

Rerunning with tests

epriestley edited edge metadata.

"Improve" in the title and summary is a little vague -- the actual improvement here is "Exclude variables used in strings inside closures when checking for undeclared variables", right? If not, I reviewed this wrong. :)

This revision is now accepted and ready to land.Aug 20 2015, 12:35 PM

Yeah, I got lazy. Will fix before landing,

joshuaspence retitled this revision from Improvement to undeclared variable linter rule to Exclude variables used in strings inside closures when checking for undeclared variables.Aug 20 2015, 9:25 PM
joshuaspence updated this object.
joshuaspence edited edge metadata.
joshuaspence updated this object.
This revision was automatically updated to reflect the committed changes.