diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 722bea0a..f8b6a685 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -171,6 +171,7 @@ phutil_register_library_map(array( 'ArcanistMissingLinterException' => 'lint/linter/exception/ArcanistMissingLinterException.php', 'ArcanistModifierOrderingXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistModifierOrderingXHPASTLinterRule.php', 'ArcanistNamingConventionsXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php', + 'ArcanistNewlineAfterOpenTagXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistNewlineAfterOpenTagXHPASTLinterRule.php', 'ArcanistNoEffectException' => 'exception/usage/ArcanistNoEffectException.php', 'ArcanistNoEngineException' => 'exception/usage/ArcanistNoEngineException.php', 'ArcanistNoLintLinter' => 'lint/linter/ArcanistNoLintLinter.php', @@ -455,6 +456,7 @@ phutil_register_library_map(array( 'ArcanistMissingLinterException' => 'Exception', 'ArcanistModifierOrderingXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistNamingConventionsXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', + 'ArcanistNewlineAfterOpenTagXHPASTLinterRule' => 'ArcanistXHPASTLinterRule', 'ArcanistNoEffectException' => 'ArcanistUsageException', 'ArcanistNoEngineException' => 'ArcanistUsageException', 'ArcanistNoLintLinter' => 'ArcanistLinter', diff --git a/src/lint/linter/__tests__/xhpast/array-comma.lint-test b/src/lint/linter/__tests__/xhpast/array-comma.lint-test index 6945002c..51128f2e 100644 --- a/src/lint/linter/__tests__/xhpast/array-comma.lint-test +++ b/src/lint/linter/__tests__/xhpast/array-comma.lint-test @@ -1,4 +1,5 @@ 'val1', $a => 'val2', @@ -34,9 +35,9 @@ $f = array( $a => 'var2', ); ~~~~~~~~~~ -error:5:3 -error:8:3 -error:15:3 -error:20:3 -error:25:3 -error:34:3 +error:6:3 +error:9:3 +error:16:3 +error:21:3 +error:26:3 +error:35:3 diff --git a/src/lint/linter/__tests__/xhpast/duplicate-switch-case.lint-test b/src/lint/linter/__tests__/xhpast/duplicate-switch-case.lint-test index 309e04d6..2c8e5c5c 100644 --- a/src/lint/linter/__tests__/xhpast/duplicate-switch-case.lint-test +++ b/src/lint/linter/__tests__/xhpast/duplicate-switch-case.lint-test @@ -1,4 +1,5 @@ + + + + + + + + + + doSomething(); id(new Something()) ->doSomething(); ~~~~~~~~~~ -warning:2:3 -warning:2:6 +warning:3:3 +warning:3:6 ~~~~~~~~~~ doSomething(); id(new Something()) ->doSomething(); diff --git a/src/lint/linter/__tests__/xhpast/parens-hug-contents.lint-test b/src/lint/linter/__tests__/xhpast/parens-hug-contents.lint-test index c0058bc0..d6a38e88 100644 --- a/src/lint/linter/__tests__/xhpast/parens-hug-contents.lint-test +++ b/src/lint/linter/__tests__/xhpast/parens-hug-contents.lint-test @@ -1,4 +1,5 @@ $y, ); ~~~~~~~~~~ -warning:3:3 -warning:3:5 -warning:4:4 -warning:5:3 -warning:12:9 -warning:13:10 -warning:14:9 -warning:24:5 +warning:4:3 +warning:4:5 +warning:5:4 +warning:6:3 +warning:13:9 +warning:14:10 +warning:15:9 +warning:25:5 ~~~~~~~~~~ 500) of string concatenations. We emit n_CONCATENATION_LIST instead of // n_BINARY_EXPRESSION to avoid various call-depth traps in PHP, HPHP, and the @@ -43,6 +44,7 @@ ~~~~~~~~~~ ~~~~~~~~~~ 500) of string concatenations. We emit n_CONCATENATION_LIST instead of // n_BINARY_EXPRESSION to avoid various call-depth traps in PHP, HPHP, and the diff --git a/src/lint/linter/__tests__/xhpast/use-of-this-in-static-method.lint-test b/src/lint/linter/__tests__/xhpast/use-of-this-in-static-method.lint-test index 3ae1214b..395939bb 100644 --- a/src/lint/linter/__tests__/xhpast/use-of-this-in-static-method.lint-test +++ b/src/lint/linter/__tests__/xhpast/use-of-this-in-static-method.lint-test @@ -8,7 +8,6 @@ final class A { $this->f(); } } - ~~~~~~~~~~ error:3:13 XHP19 Class-Filename Mismatch error:8:5 Use of $this in a static method. diff --git a/src/lint/linter/__tests__/xhpast/variable-variables.lint-test b/src/lint/linter/__tests__/xhpast/variable-variables.lint-test index d3e9a2f1..60c06632 100644 --- a/src/lint/linter/__tests__/xhpast/variable-variables.lint-test +++ b/src/lint/linter/__tests__/xhpast/variable-variables.lint-test @@ -1,5 +1,6 @@ $bar; // okay ~~~~~~~~~~ -error:2:1 +error:3:1 diff --git a/src/lint/linter/__tests__/xhpast/wrong-concat-operator.lint-test b/src/lint/linter/__tests__/xhpast/wrong-concat-operator.lint-test index 70f2450d..3910c597 100644 --- a/src/lint/linter/__tests__/xhpast/wrong-concat-operator.lint-test +++ b/src/lint/linter/__tests__/xhpast/wrong-concat-operator.lint-test @@ -1,9 +1,10 @@ selectTokensOfType('T_OPEN_TAG'); + + foreach ($tokens as $token) { + for ($next = $token->getNextToken(); + $next; + $next = $next->getNextToken()) { + + if ($next->getTypeName() == 'T_WHITESPACE' && + preg_match('/\n\s*\n/', $next->getValue())) { + continue 2; + } + + if ($token->getLineNumber() != $next->getLineNumber()) { + break; + } + + if ($next->getTypeName() == 'T_CLOSE_TAG') { + continue 2; + } + } + + $next = $token->getNextToken(); + $this->raiseLintAtToken( + $next, + pht('`%s` should be separated from code by an empty line.', 'getValue()); + } + } + +}