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
F13091729: D13938.diff
Thu, Apr 25, 3:11 AM
Unknown Object (File)
Wed, Apr 24, 8:48 AM
Unknown Object (File)
Fri, Apr 19, 1:06 AM
Unknown Object (File)
Thu, Apr 11, 10:38 AM
Unknown Object (File)
Mar 20 2024, 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
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
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 7685
Build 8407: [Placeholder Plan] Wait for 30 Seconds
Build 8406: arc lint + arc unit

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.