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.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 20, 5:41 PM
Unknown Object (File)
Feb 9 2024, 10:18 PM
Unknown Object (File)
Jan 28 2024, 5:14 PM
Unknown Object (File)
Jan 28 2024, 8:17 AM
Unknown Object (File)
Jan 28 2024, 8:16 AM
Unknown Object (File)
Jan 1 2024, 5:01 PM
Unknown Object (File)
Dec 28 2023, 5:10 PM
Unknown Object (File)
Dec 24 2023, 5:30 PM
Subscribers

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.