]> khamidou — GitHub mirrors - arcanist.git/commit
Exclude variables used in strings inside closures when checking for undeclared variables
authorJoshua Spence <josh@freelancer.com>
Thu, 20 Aug 2015 21:26:52 +0000 (07:26 +1000)
committerJoshua Spence <josh@freelancer.com>
Thu, 20 Aug 2015 21:26:52 +0000 (07:26 +1000)
commit9b8c9d280ea47e7256dd1ac0ff17fe4aa363477e
treed1884b7efd85281e2ae137263c9cb774c35c5e44
parente56f326cf72e26a05fc164cbcac7855912d954a2
Exclude variables used in strings inside closures when checking for undeclared variables

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

```lang=php
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.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13938
src/lint/linter/__tests__/xhpast/undeclared-variables.lint-test
src/lint/linter/xhpast/rules/ArcanistUndeclaredVariableXHPASTLinterRule.php