mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 16:22:42 +01:00
Fix two linter issues
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
This commit is contained in:
parent
721bdf424b
commit
a3c3d23dd7
3 changed files with 17 additions and 5 deletions
|
@ -63,8 +63,8 @@ final class ArcanistPhpLinter extends ArcanistExternalLinter {
|
|||
// 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();
|
||||
|
|
|
@ -1902,9 +1902,13 @@ final class ArcanistXHPASTLinter extends ArcanistBaseXHPASTLinter {
|
|||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,13 @@ function i() {
|
|||
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
|
||||
|
@ -65,3 +72,4 @@ warning:29:3
|
|||
warning:30:3
|
||||
warning:31:3
|
||||
warning:33:3
|
||||
warning:55:3
|
||||
|
|
Loading…
Reference in a new issue