Summary:
- The "exclude static variable access" branch in XHPAST incorrectly excluded all variables in a function or method which used any static access (we were selecting the wrong root node for exclusion).
- The "PHPLinter" regexp did not work with 5.4.30. Make it more permissive in what it parses.
Test Plan:
- Added a failing unit test for the variable case and made it pass.
- PHPLinter tests now pass under 5.4.30
Reviewers: joshuaspence, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Differential Revision: https://secure.phabricator.com/D11087
// Combine $stdout and $stderr for consistency
$stdout = $stderr."\n".$stdout;
$matches = array();
- $regex = '/PHP (?<type>.+?) error:\s+(?<error>.*?)\s+in\s+(?<file>.*?)'.
- '\s+on line\s+(?<line>\d*)/';
+ $regex = '/^(?<type>.+?) error:\s+(?<error>.*?)\s+in\s+(?<file>.*?)'.
+ '\s+on line\s+(?<line>\d*)$/m';
if (preg_match($regex, $stdout, $matches)) {
$type = strtolower($matches['type']);
$message = new ArcanistLintMessage();
$statics = $def->selectDescendantsOfType('n_CLASS_STATIC_ACCESS');
foreach ($statics as $static) {
$rhs = $static->getChildByIndex(1);
- $rhs_vars = $def->selectDescendantsOfType('n_VARIABLE');
- foreach ($rhs_vars as $var) {
- $exclude_tokens[$var->getID()] = true;
+ if ($rhs->getTypeName() == 'n_VARIABLE') {
+ $exclude_tokens[$rhs->getID()] = true;
+ } else {
+ $rhs_vars = $rhs->selectDescendantsOfType('n_VARIABLE');
+ foreach ($rhs_vars as $var) {
+ $exclude_tokens[$var->getID()] = true;
+ }
}
}
Other::$Y_y[0];
parent::$Z_z[0];
}
+
+function j() {
+ // Test case for bug where any static access would shadow other variables.
+ Other::$y = 0;
+ $mIxEdCaSe = 1;
+}
+
~~~~~~~~~~
warning:2:13
warning:3:9
warning:30:3
warning:31:3
warning:33:3
+warning:55:3