Page MenuHomePhabricator

D14488.id35047.diff
No OneTemporary

D14488.id35047.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -339,6 +339,7 @@
'ArcanistUnnecessaryFinalModifierXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistUnnecessaryFinalModifierXHPASTLinterRule.php',
'ArcanistUnnecessaryFinalModifierXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistUnnecessaryFinalModifierXHPASTLinterRuleTestCase.php',
'ArcanistUnnecessarySemicolonXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistUnnecessarySemicolonXHPASTLinterRule.php',
+ 'ArcanistUnnecessarySemicolonXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistUnnecessarySemicolonXHPASTLinterRuleTestCase.php',
'ArcanistUnsafeDynamicStringXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php',
'ArcanistUnsafeDynamicStringXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistUnsafeDynamicStringXHPASTLinterRuleTestCase.php',
'ArcanistUpgradeWorkflow' => 'workflow/ArcanistUpgradeWorkflow.php',
@@ -709,6 +710,7 @@
'ArcanistUnnecessaryFinalModifierXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistUnnecessaryFinalModifierXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistUnnecessarySemicolonXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
+ 'ArcanistUnnecessarySemicolonXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistUnsafeDynamicStringXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistUnsafeDynamicStringXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistUpgradeWorkflow' => 'ArcanistWorkflow',
diff --git a/src/lint/linter/xhpast/rules/ArcanistArrayCombineXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistArrayCombineXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistArrayCombineXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistArrayCombineXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 84;
public function getLintName() {
- return pht('%s Unreliable', 'array_combine()');
+ return pht('`%s` Unreliable', 'array_combine');
}
public function getLintSeverity() {
@@ -34,9 +34,9 @@
pht(
'Prior to PHP 5.4, `%s` fails when given empty arrays. '.
'Prefer to write `%s` as `%s`.',
- 'array_combine()',
- 'array_combine(x, x)',
- 'array_fuse(x)'));
+ 'array_combine',
+ 'array_combine($x, $x)',
+ 'array_fuse($x)'));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistCallTimePassByReferenceXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistCallTimePassByReferenceXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistCallTimePassByReferenceXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistCallTimePassByReferenceXHPASTLinterRule.php
@@ -18,7 +18,10 @@
foreach ($parameters as $parameter) {
$this->raiseLintAtNode(
$parameter,
- pht('Call-time pass-by-reference calls are prohibited.'));
+ pht(
+ 'Call-time pass-by-reference calls are prohibited. '.
+ 'As of PHP 5.4.0, call-time pass-by-reference was removed '.
+ 'and so using this functionality will raise a fatal error.'));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistClassExtendsObjectXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistClassExtendsObjectXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistClassExtendsObjectXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistClassExtendsObjectXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 88;
public function getLintName() {
- return pht('Class Not Extending %s', 'Phobject');
+ return pht('Class Not Extending `%s`', 'Phobject');
}
public function getLintSeverity() {
@@ -29,8 +29,8 @@
$this->raiseLintAtNode(
$class,
pht(
- 'Classes should extend from %s or from some other class. '.
- 'All classes (except for %s itself) should have a base class.',
+ 'Classes should extend from `%s` or from some other class. '.
+ 'All classes (except for `%s` itself) should have a base class.',
'Phobject',
'Phobject'));
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistClassFilenameMismatchXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistClassFilenameMismatchXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistClassFilenameMismatchXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistClassFilenameMismatchXHPASTLinterRule.php
@@ -47,7 +47,7 @@
$decl_name,
pht(
"The name of this file differs from the name of the ".
- "class or interface it declares. Rename the file to '%s'.",
+ 'class or interface it declares. Rename the file to `%s`.',
$rename));
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistClassNameLiteralXHPASTLinterRule.php
@@ -39,7 +39,7 @@
$this->raiseLintAtNode(
$string,
pht(
- "Don't hard-code class names, use %s instead.",
+ "Don't hard-code class names, use `%s` instead.",
'__CLASS__'),
$replacement);
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistCommentStyleXHPASTLinterRule.php
@@ -10,7 +10,9 @@
}
public function process(XHPASTNode $root) {
- foreach ($root->selectTokensOfType('T_COMMENT') as $comment) {
+ $comments = $root->selectTokensOfType('T_COMMENT');
+
+ foreach ($comments as $comment) {
$value = $comment->getValue();
if ($value[0] !== '#') {
@@ -19,7 +21,10 @@
$this->raiseLintAtOffset(
$comment->getOffset(),
- pht('Use "%s" single-line comments, not "%s".', '//', '#'),
+ pht(
+ 'Use `%s` single-line comments, not `%s`.',
+ '//',
+ '#'),
'#',
preg_match('/^#\S/', $value) ? '// ' : '//');
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistDeclarationParenthesesXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistDeclarationParenthesesXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistDeclarationParenthesesXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistDeclarationParenthesesXHPASTLinterRule.php
@@ -78,7 +78,9 @@
if (!$before) {
$this->raiseLintAtOffset(
$use->getOffset(),
- pht('Convention: space before `%s` token.', 'use'),
+ pht(
+ 'Convention: space before `%s` token.',
+ 'use'),
'',
' ');
}
@@ -86,7 +88,9 @@
if (!$after) {
$this->raiseLintAtOffset(
$use->getOffset() + strlen($use->getValue()),
- pht('Convention: space after `%s` token.', 'use'),
+ pht(
+ 'Convention: space after `%s` token.',
+ 'use'),
'',
' ');
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistDynamicDefineXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistDynamicDefineXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistDynamicDefineXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistDynamicDefineXHPASTLinterRule.php
@@ -6,22 +6,23 @@
const ID = 12;
public function getLintName() {
- return pht('Dynamic %s', 'define()');
+ return pht('Dynamic `%s`', 'define()');
}
public function process(XHPASTNode $root) {
- $calls = $this->getFunctionCalls($root, array('define'));
+ $defines = $this->getFunctionCalls($root, array('define'));
- foreach ($calls as $call) {
- $parameter_list = $call->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
- $defined = $parameter_list->getChildByIndex(0);
+ foreach ($defines as $define) {
+ $key = $define
+ ->getChildOfType(1, 'n_CALL_PARAMETER_LIST')
+ ->getChildByIndex(0);
- if (!$defined->isStaticScalar()) {
+ if (!$key->isStaticScalar()) {
$this->raiseLintAtNode(
- $defined,
+ $key,
pht(
- 'First argument to %s must be a string literal.',
- 'define()'));
+ 'First argument to `%s` must be a string literal.',
+ 'define'));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistElseIfUsageXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistElseIfUsageXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistElseIfUsageXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistElseIfUsageXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 42;
public function getLintName() {
- return pht('ElseIf Usage');
+ return pht('`%s` Usage', 'elseif');
}
public function getLintSeverity() {
@@ -19,7 +19,10 @@
foreach ($tokens as $token) {
$this->raiseLintAtToken(
$token,
- pht('Usage of `%s` is preferred over `%s`.', 'else if', 'elseif'),
+ pht(
+ 'Usage of `%s` is preferred over `%s`.',
+ 'else if',
+ 'elseif'),
'else if');
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistExtractUseXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistExtractUseXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistExtractUseXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistExtractUseXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 4;
public function getLintName() {
- return pht('Use of %s', 'extract()');
+ return pht('Use of `%s`', 'extract');
}
public function process(XHPASTNode $root) {
@@ -16,8 +16,9 @@
$this->raiseLintAtNode(
$call,
pht(
- 'Avoid %s. It is confusing and hinders static analysis.',
- 'extract()'));
+ 'Avoid the `%s` function. '.
+ 'It is confusing and hinders static analysis.',
+ 'extract'));
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistImplicitConstructorXHPASTLinterRule.php
@@ -24,8 +24,9 @@
$this->raiseLintAtNode(
$method_name_token,
pht(
- 'Name constructors %s explicitly. This method is a constructor '.
- ' because it has the same name as the class it is defined in.',
+ 'Name constructors `%s` explicitly. This method is a '.
+ 'constructor because it has the same name as the class '.
+ 'it is defined in.',
'__construct()'));
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistInnerFunctionXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistInnerFunctionXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistInnerFunctionXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistInnerFunctionXHPASTLinterRule.php
@@ -17,8 +17,8 @@
$function_decls = $root->selectDescendantsOfType('n_FUNCTION_DECLARATION');
foreach ($function_decls as $function_declaration) {
- $inner_functions = $function_declaration
- ->selectDescendantsOfType('n_FUNCTION_DECLARATION');
+ $inner_functions = $function_declaration->selectDescendantsOfType(
+ 'n_FUNCTION_DECLARATION');
foreach ($inner_functions as $inner_function) {
if ($inner_function->getChildByIndex(2)->getTypeName() == 'n_EMPTY') {
diff --git a/src/lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistInstanceOfOperatorXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 69;
public function getLintName() {
- return pht('%s Operator', 'instanceof');
+ return pht('`%s` Operator', 'instanceof');
}
public function process(XHPASTNode $root) {
@@ -26,7 +26,7 @@
$this->raiseLintAtNode(
$object,
pht(
- '%s expects an object instance, constant given.',
+ '`%s` expects an object instance, constant given.',
'instanceof'));
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistInvalidDefaultParameterXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistInvalidDefaultParameterXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistInvalidDefaultParameterXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistInvalidDefaultParameterXHPASTLinterRule.php
@@ -39,8 +39,8 @@
$this->raiseLintAtNode(
$default,
pht(
- 'Default value for parameters with %s type hint '.
- 'can only be an %s or %s.',
+ 'Default value for parameters with `%s` type hint '.
+ 'can only be an `%s` or `%s`.',
'array',
'array',
'null'));
@@ -54,7 +54,8 @@
$this->raiseLintAtNode(
$default,
pht(
- 'Default value for parameters with %s type hint can only be %s.',
+ 'Default value for parameters with `%s` '.
+ 'type hint can only be `%s`.',
'callable',
'null'));
break;
@@ -69,7 +70,7 @@
$default,
pht(
'Default value for parameters with a class type hint '.
- 'can only be %s.',
+ 'can only be `%s`.',
'null'));
break;
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistInvalidModifiersXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistInvalidModifiersXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistInvalidModifiersXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistInvalidModifiersXHPASTLinterRule.php
@@ -30,7 +30,7 @@
$this->raiseLintAtNode(
$modifier,
pht(
- 'Properties cannot be declared %s.',
+ 'Properties cannot be declared `%s`.',
'abstract'));
}
@@ -38,7 +38,7 @@
$this->raiseLintAtNode(
$modifier,
pht(
- 'Multiple %s modifiers are not allowed.',
+ 'Multiple `%s` modifiers are not allowed.',
'abstract'));
}
@@ -46,7 +46,7 @@
$this->raiseLintAtNode(
$modifier,
pht(
- 'Cannot use the %s modifier on an %s class member',
+ 'Cannot use the `%s` modifier on an `%s` class member',
'final',
'abstract'));
}
@@ -59,7 +59,7 @@
$this->raiseLintAtNode(
$modifier,
pht(
- 'Cannot use the %s modifier on an %s class member',
+ 'Cannot use the `%s` modifier on an `%s` class member',
'final',
'abstract'));
}
@@ -68,7 +68,7 @@
$this->raiseLintAtNode(
$modifier,
pht(
- 'Multiple %s modifiers are not allowed.',
+ 'Multiple `%s` modifiers are not allowed.',
'final'));
}
@@ -91,7 +91,7 @@
$this->raiseLintAtNode(
$modifier,
pht(
- 'Multiple %s modifiers are not allowed.',
+ 'Multiple `%s` modifiers are not allowed.',
'static'));
}
break;
diff --git a/src/lint/linter/xhpast/rules/ArcanistKeywordCasingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistKeywordCasingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistKeywordCasingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistKeywordCasingXHPASTLinterRule.php
@@ -89,7 +89,7 @@
$this->raiseLintAtToken(
$keyword,
pht(
- "Convention: spell keyword '%s' as '%s'.",
+ 'Convention: spell keyword `%s` as `%s`.',
$value,
strtolower($value)),
strtolower($value));
@@ -115,7 +115,7 @@
$this->raiseLintAtNode(
$symbol,
pht(
- "Convention: spell keyword '%s' as '%s'.",
+ 'Convention: spell keyword `%s` as `%s`.',
$symbol_name,
strtolower($symbol_name)),
strtolower($symbol_name));
diff --git a/src/lint/linter/xhpast/rules/ArcanistLambdaFuncFunctionXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistLambdaFuncFunctionXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistLambdaFuncFunctionXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistLambdaFuncFunctionXHPASTLinterRule.php
@@ -6,12 +6,12 @@
const ID = 68;
public function getLintName() {
- return pht('%s Function', '__lambda_func');
+ return pht('`%s` Function', '__lambda_func');
}
public function process(XHPASTNode $root) {
- $function_declarations = $root
- ->selectDescendantsOfType('n_FUNCTION_DECLARATION');
+ $function_declarations = $root->selectDescendantsOfType(
+ 'n_FUNCTION_DECLARATION');
foreach ($function_declarations as $function_declaration) {
$function_name = $function_declaration->getChildByIndex(2);
@@ -21,17 +21,17 @@
continue;
}
- if ($function_name->getConcreteString() != '__lambda_func') {
+ if (strtolower($function_name->getConcreteString()) != '__lambda_func') {
continue;
}
$this->raiseLintAtNode(
$function_declaration,
pht(
- 'Declaring a function named %s causes any call to %s to fail. '.
- 'This is because %s eval-declares the function %s, then '.
+ 'Declaring a function named `%s` causes any call to `%s` to fail. '.
+ 'This is because `%s` eval-declares the function `%s`, then '.
'modifies the symbol table so that the function is instead '.
- 'named %s, and returns that name.',
+ 'named `%s`, and returns that name.',
'__lambda_func',
'create_function',
'create_function',
diff --git a/src/lint/linter/xhpast/rules/ArcanistLogicalOperatorsXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistLogicalOperatorsXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistLogicalOperatorsXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistLogicalOperatorsXHPASTLinterRule.php
@@ -20,14 +20,20 @@
foreach ($logical_ands as $logical_and) {
$this->raiseLintAtToken(
$logical_and,
- pht('Use `%s` instead of `%s`.', '&&', 'and'),
+ pht(
+ 'Use boolean `%s` instead of logical `%s`.',
+ '&&',
+ 'and'),
'&&');
}
foreach ($logical_ors as $logical_or) {
$this->raiseLintAtToken(
$logical_or,
- pht('Use `%s` instead of `%s`.', '||', 'or'),
+ pht(
+ 'Use boolean `%s` instead of logical `%s`.',
+ '||',
+ 'or'),
'||');
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistNamingConventionsXHPASTLinterRule.php
@@ -20,7 +20,7 @@
'xhpast.naminghook' => array(
'type' => 'optional string',
'help' => pht(
- 'Name of a concrete subclass of %s which enforces more '.
+ 'Name of a concrete subclass of `%s` which enforces more '.
'granular naming convention rules for symbols.',
'ArcanistXHPASTLintNamingHook'),
),
@@ -56,8 +56,8 @@
ArcanistXHPASTLintNamingHook::isUpperCamelCase($name_string)
? null
: pht(
- 'Follow naming conventions: classes should be named using '.
- 'UpperCamelCase.'),
+ 'Follow naming conventions: classes should be named using `%s`.',
+ 'UpperCamelCase'),
);
}
@@ -72,8 +72,8 @@
ArcanistXHPASTLintNamingHook::isUpperCamelCase($name_string)
? null
: pht(
- 'Follow naming conventions: interfaces should be named using '.
- 'UpperCamelCase.'),
+ 'Follow naming conventions: interfaces should be named using `%s`.',
+ 'UpperCamelCase'),
);
}
@@ -94,8 +94,8 @@
ArcanistXHPASTLintNamingHook::stripPHPFunction($name_string))
? null
: pht(
- 'Follow naming conventions: functions should be named using '.
- 'lowercase_with_underscores.'),
+ 'Follow naming conventions: functions should be named using `%s`.',
+ 'lowercase_with_underscores'),
);
}
@@ -112,8 +112,8 @@
ArcanistXHPASTLintNamingHook::stripPHPFunction($name_string))
? null
: pht(
- 'Follow naming conventions: methods should be named using '.
- 'lowerCamelCase.'),
+ 'Follow naming conventions: methods should be named using `%s`.',
+ 'lowerCamelCase'),
);
}
@@ -137,8 +137,9 @@
ArcanistXHPASTLintNamingHook::stripPHPVariable($name_string))
? null
: pht(
- 'Follow naming conventions: parameters should be named using '.
- 'lowercase_with_underscores.'),
+ 'Follow naming conventions: parameters '.
+ 'should be named using `%s`.',
+ 'lowercase_with_underscores'),
);
}
}
@@ -158,7 +159,8 @@
? null
: pht(
'Follow naming conventions: class constants should be named '.
- 'using UPPERCASE_WITH_UNDERSCORES.'),
+ 'using `%s`.',
+ 'UPPERCASE_WITH_UNDERSCORES'),
);
}
}
@@ -185,7 +187,8 @@
? null
: pht(
'Follow naming conventions: class properties should be named '.
- 'using lowerCamelCase.'),
+ 'using `%s`.',
+ 'lowerCamelCase'),
);
}
}
@@ -269,8 +272,9 @@
ArcanistXHPASTLintNamingHook::stripPHPVariable($var_string))
? null
: pht(
- 'Follow naming conventions: variables should be named using '.
- 'lowercase_with_underscores.'),
+ 'Follow naming conventions: variables '.
+ 'should be named using `%s`.',
+ 'lowercase_with_underscores'),
);
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistNoParentScopeXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistNoParentScopeXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistNoParentScopeXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistNoParentScopeXHPASTLinterRule.php
@@ -34,7 +34,7 @@
$this->raiseLintAtNode(
$static_access,
pht(
- 'Cannot access %s when current class scope has no parent.',
+ 'Cannot access `%s` when current class scope has no parent.',
'parent::'));
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistObjectOperatorSpacingXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistObjectOperatorSpacingXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistObjectOperatorSpacingXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistObjectOperatorSpacingXHPASTLinterRule.php
@@ -29,7 +29,9 @@
$this->raiseLintAtOffset(
head($before)->getOffset(),
- pht('There should be no whitespace before the object operator.'),
+ pht(
+ 'There should be no whitespace before the object operator (`%s`).',
+ '->'),
$value,
'');
}
@@ -37,7 +39,9 @@
if ($after) {
$this->raiseLintAtOffset(
head($after)->getOffset(),
- pht('There should be no whitespace after the object operator.'),
+ pht(
+ 'There should be no whitespace after the object operator (`%s`).',
+ '->'),
implode('', mpull($before, 'getValue')),
'');
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistPHPCloseTagXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPHPCloseTagXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPHPCloseTagXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPHPCloseTagXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 8;
public function getLintName() {
- return pht('Use of Close Tag "%s"', '?>');
+ return pht('Use of PHP Closing Tag');
}
public function process(XHPASTNode $root) {
@@ -16,10 +16,14 @@
return;
}
- foreach ($root->selectTokensOfType('T_CLOSE_TAG') as $token) {
+ $tokens = $root->selectTokensOfType('T_CLOSE_TAG');
+
+ foreach ($tokens as $token) {
$this->raiseLintAtToken(
$token,
- pht('Do not use the PHP closing tag, "%s".', '?>'));
+ pht(
+ 'Do not use the PHP closing tag (`%s`).',
+ '?>'));
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPHPCompatibilityXHPASTLinterRule.php
@@ -115,7 +115,7 @@
$this->raiseLintAtNode(
$node,
pht(
- 'This codebase targets PHP %s, but `%s()` was not '.
+ 'This codebase targets PHP %s, but `%s` was not '.
'introduced until PHP %s.',
$this->version,
$name,
@@ -124,8 +124,7 @@
$this->raiseLintAtNode(
$node,
pht(
- 'This codebase targets PHP %s, but `%s()` was '.
- 'removed in PHP %s.',
+ 'This codebase targets PHP %s, but `%s` was removed in PHP %s.',
$this->version,
$name,
$max));
@@ -138,7 +137,7 @@
$param,
pht(
'This codebase targets PHP %s, but parameter %d '.
- 'of `%s()` was not introduced until PHP %s.',
+ 'of `%s` was not introduced until PHP %s.',
$this->version,
$i + 1,
$name,
@@ -155,7 +154,7 @@
$node,
pht(
'This codebase targets PHP %s on Windows, '.
- 'but `%s()` is not available there.',
+ 'but `%s` is not available there.',
$this->windowsVersion,
$name));
} else if (version_compare($windows, $this->windowsVersion, '>')) {
@@ -163,7 +162,7 @@
$node,
pht(
'This codebase targets PHP %s on Windows, '.
- 'but `%s()` is not available there until PHP %s.',
+ 'but `%s` is not available there until PHP %s.',
$this->windowsVersion,
$name,
$windows));
@@ -363,9 +362,9 @@
$this->raiseLintAtNode(
$index->getChildByIndex(1),
pht(
- 'The `%s` syntax was not introduced until PHP 5.4, but this '.
- 'codebase targets an earlier version of PHP. You can rewrite '.
- 'this expression using `%s`.',
+ 'The `%s` syntax was not introduced until PHP 5.4, '.
+ 'but this codebase targets an earlier version of PHP. '.
+ 'You can rewrite this expression using `%s`.',
'f()[...]',
'idx()'));
break;
diff --git a/src/lint/linter/xhpast/rules/ArcanistPHPEchoTagXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPHPEchoTagXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPHPEchoTagXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPHPEchoTagXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 7;
public function getLintName() {
- return pht('Use of Echo Tag "%s"', '<?=');
+ return pht('Use of PHP Echo Tag');
}
public function process(XHPASTNode $root) {
@@ -16,7 +16,9 @@
if ($token->getTypeName() === 'T_OPEN_TAG_WITH_ECHO') {
$this->raiseLintAtToken(
$token,
- pht('Avoid the PHP echo short form, "%s".', '<?='));
+ pht(
+ 'Avoid the PHP echo tag, `%s`.',
+ '<?='));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPHPOpenTagXHPASTLinterRule.php
@@ -22,8 +22,8 @@
$this->raiseLintAtToken(
$token,
pht(
- 'PHP files should start with "%s", which may be preceded by '.
- 'a "%s" line for scripts.',
+ 'PHP files should start with `%s`, which may be preceded by '.
+ 'a `%s` line for scripts.',
'<?php',
'#!'));
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistPHPShortTagXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPHPShortTagXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPHPShortTagXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPHPShortTagXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 6;
public function getLintName() {
- return pht('Use of Short Tag "%s"', '<?');
+ return pht('Use of PHP Short Tag');
}
public function process(XHPASTNode $root) {
@@ -18,7 +18,7 @@
$this->raiseLintAtToken(
$token,
pht(
- 'Use the full form of the PHP open tag, "%s".',
+ 'Use the full form of the PHP open tag, `%s`.',
'<?php'),
"<?php\n");
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistParseStrUseXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistParseStrUseXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistParseStrUseXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistParseStrUseXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 80;
public function getLintName() {
- return pht('Questionable Use of %s', 'parse_str()');
+ return pht('Questionable Use of `%s`', 'parse_str');
}
public function process(XHPASTNode $root) {
@@ -19,9 +19,9 @@
$this->raiseLintAtNode(
$call,
pht(
- 'Avoid %s unless the second parameter is specified. '.
+ 'Avoid `%s` unless the second parameter is specified. '.
'It is confusing and hinders static analysis.',
- 'parse_str()'));
+ 'parse_str'));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistPlusOperatorOnStringsXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPlusOperatorOnStringsXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPlusOperatorOnStringsXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPlusOperatorOnStringsXHPASTLinterRule.php
@@ -26,9 +26,10 @@
$this->raiseLintAtNode(
$binop,
pht(
- "In PHP, '%s' is the string concatenation operator, not '%s'. ".
- "This expression uses '+' with a string literal as an operand.",
+ 'In PHP, `%s` is the string concatenation operator, not `%s`. '.
+ 'This expression uses `%s` with a string literal as an operand.',
'.',
+ '+',
'+'));
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistPregQuoteMisuseXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistPregQuoteMisuseXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistPregQuoteMisuseXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistPregQuoteMisuseXHPASTLinterRule.php
@@ -12,7 +12,7 @@
const ID = 14;
public function getLintName() {
- return pht('Misuse of %s', 'preg_quote()');
+ return pht('Misuse of `%s`', 'preg_quote');
}
public function getLintSeverity() {
@@ -23,19 +23,24 @@
$function_calls = $this->getFunctionCalls($root, array('preg_quote'));
foreach ($function_calls as $call) {
- $parameter_list = $call->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
- if (count($parameter_list->getChildren()) !== 2) {
- $this->raiseLintAtNode(
- $call,
- pht(
- 'If you use pattern delimiters that require escaping '.
- '(such as `%s`, but not `%s`) then you should pass two '.
- 'arguments to %s, so that %s knows which delimiter to escape.',
- '//',
- '()',
- 'preg_quote()',
- 'preg_quote()'));
+ $parameters = $call
+ ->getChildOfType(1, 'n_CALL_PARAMETER_LIST')
+ ->getChildren();
+
+ if (count($parameters) == 2) {
+ continue;
}
+
+ $this->raiseLintAtNode(
+ $call,
+ pht(
+ 'If you use pattern delimiters that require escaping '.
+ '(such as `%s`, but not `%s`) then you should pass two '.
+ 'arguments to `%s`, so that `%s` knows which delimiter to escape.',
+ '//',
+ '()',
+ 'preg_quote',
+ 'preg_quote'));
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistRaggedClassTreeEdgeXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistRaggedClassTreeEdgeXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistRaggedClassTreeEdgeXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistRaggedClassTreeEdgeXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 87;
public function getLintName() {
- return pht('Class Not %s Or %s', 'abstract', 'final');
+ return pht('Class Not `%s` Or `%s`', 'abstract', 'final');
}
public function getLintSeverity() {
@@ -14,25 +14,28 @@
}
public function process(XHPASTNode $root) {
- $parser = new PhutilDocblockParser();
-
$classes = $root->selectDescendantsOfType('n_CLASS_DECLARATION');
+ $parser = new PhutilDocblockParser();
+
foreach ($classes as $class) {
$is_final = false;
$is_abstract = false;
$is_concrete_extensible = false;
$attributes = $class->getChildOfType(0, 'n_CLASS_ATTRIBUTES');
- foreach ($attributes->getChildren() as $child) {
- if ($child->getConcreteString() == 'final') {
- $is_final = true;
- }
- if ($child->getConcreteString() == 'abstract') {
- $is_abstract = true;
+ $docblock = $class->getDocblockToken();
+
+ foreach ($attributes->getChildren() as $attribute) {
+ switch (strtolower($attribute->getConcreteString())) {
+ case 'abstract':
+ $is_abstract = true;
+ break;
+ case 'final':
+ $is_final = true;
+ break;
}
}
- $docblock = $class->getDocblockToken();
if ($docblock) {
list($text, $specials) = $parser->parse($docblock->getValue());
$is_concrete_extensible = idx($specials, 'concrete-extensible');
@@ -40,10 +43,10 @@
if (!$is_final && !$is_abstract && !$is_concrete_extensible) {
$this->raiseLintAtNode(
- $class->getChildOfType(1, 'n_CLASS_NAME'),
+ $class,
pht(
- "This class is neither '%s' nor '%s', and does not have ".
- "a docblock marking it '%s'.",
+ 'This class is neither `%s` nor `%s`, and does not have '.
+ 'a docblock marking it `%s`.',
'final',
'abstract',
'@concrete-extensible'));
diff --git a/src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistReusedAsIteratorXHPASTLinterRule.php
@@ -90,7 +90,7 @@
if ($lval->getTypeName() === 'n_VARIABLE') {
$vars[] = $lval;
} else if ($lval->getTypeName() === 'n_LIST') {
- // Recursivey grab everything out of list(), since the grammar
+ // Recursively grab everything out of list(), since the grammar
// permits list() to be nested. Also note that list() is ONLY valid
// as an lval assignments, so we could safely lift this out of the
// n_BINARY_EXPRESSION branch.
diff --git a/src/lint/linter/xhpast/rules/ArcanistReusedIteratorReferenceXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistReusedIteratorReferenceXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistReusedIteratorReferenceXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistReusedIteratorReferenceXHPASTLinterRule.php
@@ -173,7 +173,7 @@
$var,
pht(
'This variable was used already as a by-reference iterator '.
- 'variable. Such variables survive outside the %s loop, '.
+ 'variable. Such variables survive outside the `%s` loop, '.
'do not reuse.',
'foreach'));
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistSlownessXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistSlownessXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistSlownessXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistSlownessXHPASTLinterRule.php
@@ -51,14 +51,14 @@
$this->raiseLintAtNode(
$strstr,
pht(
- 'Use %s for checking if the string contains something.',
- 'strpos()'));
+ 'Use `%s` for checking if the string contains something.',
+ 'strpos'));
} else if ($name === 'stristr') {
$this->raiseLintAtNode(
$strstr,
pht(
- 'Use %s for checking if the string contains something.',
- 'stripos()'));
+ 'Use `%s` for checking if the string contains something.',
+ 'stripos'));
}
}
}
@@ -96,14 +96,14 @@
$this->raiseLintAtNode(
$strpos,
pht(
- 'Use %s for checking if the string starts with something.',
- 'strncmp()'));
+ 'Use `%s` for checking if the string starts with something.',
+ 'strncmp'));
} else if ($name === 'stripos') {
$this->raiseLintAtNode(
$strpos,
pht(
- 'Use %s for checking if the string starts with something.',
- 'strncasecmp()'));
+ 'Use `%s` for checking if the string starts with something.',
+ 'strncasecmp'));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistStaticThisXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 13;
public function getLintName() {
- return pht('Use of %s in Static Context', '$this');
+ return pht('Use of `%s` in Static Context', '$this');
}
public function process(XHPASTNode $root) {
diff --git a/src/lint/linter/xhpast/rules/ArcanistToStringExceptionXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistToStringExceptionXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistToStringExceptionXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistToStringExceptionXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 67;
public function getLintName() {
- return pht('Throwing Exception in %s Method', '__toString');
+ return pht('Throwing Exception in `%s` Method', '__toString');
}
public function process(XHPASTNode $root) {
@@ -17,23 +17,22 @@
->getChildOfType(2, 'n_STRING')
->getConcreteString();
- if ($name != '__toString') {
+ if (strtolower($name) != '__tostring') {
continue;
}
$statements = $method->getChildByIndex(5);
-
if ($statements->getTypeName() != 'n_STATEMENT_LIST') {
continue;
}
$throws = $statements->selectDescendantsOfType('n_THROW');
-
foreach ($throws as $throw) {
$this->raiseLintAtNode(
$throw,
pht(
- 'It is not possible to throw an %s from within the %s method.',
+ 'It is not possible to throw an `%s` from within the `%s` method. '.
+ 'Any attempt to do so will result in a fatal error.',
'Exception',
'__toString'));
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistUnnecessaryFinalModifierXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnnecessaryFinalModifierXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUnnecessaryFinalModifierXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUnnecessaryFinalModifierXHPASTLinterRule.php
@@ -6,7 +6,7 @@
const ID = 55;
public function getLintName() {
- return pht('Unnecessary Final Modifier');
+ return pht('Unnecessary `%s` Modifier', 'final');
}
public function getLintSeverity() {
@@ -40,7 +40,7 @@
$this->raiseLintAtNode(
$attribute,
pht(
- 'Unnecessary %s modifier in %s class.',
+ 'Unnecessary `%s` modifier in `%s` class.',
'final',
'final'));
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistUnnecessarySemicolonXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnnecessarySemicolonXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUnnecessarySemicolonXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUnnecessarySemicolonXHPASTLinterRule.php
@@ -23,14 +23,16 @@
if (count($statement->getChildren()) > 1) {
continue;
- } else if ($statement->getChildByIndex(0)->getTypeName() != 'n_EMPTY') {
+ }
+
+ if ($statement->getChildByIndex(0)->getTypeName() != 'n_EMPTY') {
continue;
}
if ($statement->getConcreteString() == ';') {
$this->raiseLintAtNode(
$statement,
- pht('Unnecessary semicolons after statement.'),
+ pht('Unnecessary semicolon after statement.'),
'');
}
}
diff --git a/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php b/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/rules/ArcanistUnsafeDynamicStringXHPASTLinterRule.php
@@ -92,10 +92,10 @@
$this->raiseLintAtNode(
$call,
pht(
- "Parameter %d of %s should be a scalar string, ".
+ "Parameter %d of `%s` should be a scalar string, ".
"otherwise it's not safe.",
$param + 1,
- $name.'()'));
+ $name));
}
}
}
diff --git a/src/lint/linter/xhpast/rules/__tests__/ArcanistPHPCloseTagXHPASTLinterRuleTestCase.php b/src/lint/linter/xhpast/rules/__tests__/ArcanistPHPCloseTagXHPASTLinterRuleTestCase.php
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/ArcanistPHPCloseTagXHPASTLinterRuleTestCase.php
@@ -0,0 +1,10 @@
+<?php
+
+final class ArcanistPHPCloseTagXHPASTLinterRuleTestCase
+ extends ArcanistXHPASTLinterRuleTestCase {
+
+ public function testLinter() {
+ $this->executeTestsInDirectory(dirname(__FILE__).'/php-close-tag/');
+ }
+
+}
diff --git a/src/lint/linter/xhpast/rules/__tests__/ArcanistUnnecessarySemicolonXHPASTLinterRuleTestCase.php b/src/lint/linter/xhpast/rules/__tests__/ArcanistUnnecessarySemicolonXHPASTLinterRuleTestCase.php
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/ArcanistUnnecessarySemicolonXHPASTLinterRuleTestCase.php
@@ -0,0 +1,10 @@
+<?php
+
+final class ArcanistUnnecessarySemicolonXHPASTLinterRuleTestCase
+ extends ArcanistXHPASTLinterRuleTestCase {
+
+ public function testLinter() {
+ $this->executeTestsInDirectory(dirname(__FILE__).'/unnecessary-semicolon/');
+ }
+
+}
diff --git a/src/lint/linter/xhpast/rules/__tests__/__lambda_func-function/lamba-func-function.lint-test b/src/lint/linter/xhpast/rules/__tests__/__lambda_func-function/__lambda_func.lint-test
rename from src/lint/linter/xhpast/rules/__tests__/__lambda_func-function/lamba-func-function.lint-test
rename to src/lint/linter/xhpast/rules/__tests__/__lambda_func-function/__lambda_func.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/__lambda_func-function/lamba-func-function.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/__lambda_func-function/__lambda_func.lint-test
@@ -1,5 +1,4 @@
<?php
-
function __lambda_func() {}
~~~~~~~~~~
-error:3:1
+error:2:1
diff --git a/src/lint/linter/xhpast/rules/__tests__/__toString-exception/abstract.lint-test b/src/lint/linter/xhpast/rules/__tests__/__toString-exception/abstract.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/__toString-exception/abstract.lint-test
@@ -0,0 +1,5 @@
+<?php
+abstract class SomeAbstractClass {
+ abstract public function __toString();
+}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/__toString-exception/__toString-exception.lint-test b/src/lint/linter/xhpast/rules/__tests__/__toString-exception/exception.lint-test
rename from src/lint/linter/xhpast/rules/__tests__/__toString-exception/__toString-exception.lint-test
rename to src/lint/linter/xhpast/rules/__tests__/__toString-exception/exception.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/__toString-exception/__toString-exception.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/__toString-exception/exception.lint-test
@@ -1,27 +1,19 @@
<?php
-
class MyClass {
public function __toString() {
- if (some_function()) {
- throw new Exception('Oops');
- }
-
- return __CLASS__;
+ throw new Exception('Oops');
}
}
class MyOtherClass {
public function __toString() {
- return 'Success';
- }
-}
-
-interface SomeInterface {
- public function __toString();
-}
+ if (some_function()) {
+ throw new Exception('Oops');
+ }
-abstract class SomeAbstractClass {
- abstract public function __toString();
+ return 'quack';
+ }
}
~~~~~~~~~~
-error:6:7
+error:4:5
+error:11:7
diff --git a/src/lint/linter/xhpast/rules/__tests__/__toString-exception/interface.lint-test b/src/lint/linter/xhpast/rules/__tests__/__toString-exception/interface.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/__toString-exception/interface.lint-test
@@ -0,0 +1,5 @@
+<?php
+interface SomeInterface {
+ public function __toString();
+}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/__toString-exception/noexception.lint-test b/src/lint/linter/xhpast/rules/__tests__/__toString-exception/noexception.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/__toString-exception/noexception.lint-test
@@ -0,0 +1,7 @@
+<?php
+class MyClass {
+ public function __toString() {
+ return 'quack';
+ }
+}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/array.lint-test b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/array.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/array.lint-test
@@ -0,0 +1,3 @@
+<?php
+some_func(array(&$x, &$y));
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/bitwise.lint-test b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/bitwise.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/bitwise.lint-test
@@ -0,0 +1,3 @@
+<?php
+sprintf('0%o', 0777 & $p);
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/call-time-pass-by-reference.lint-test b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/call-time-pass-by-reference.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/call-time-pass-by-reference.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/call-time-pass-by-reference.lint-test
@@ -1,33 +1,17 @@
<?php
-class MyClass {
- public function myfunc($var) {
- echo $var;
- }
-}
+some_func(&$x);
+some_func($x);
-$myvar = true;
-myfunc(&$myvar);
-myfunc($myvar);
+$y->someMethod(&$x);
+$y->someMethod($x);
-$this->myfunc(&$myvar);
-$this->myfunc($myvar);
+SomeClass::someMethod(&$x);
+SomeClass::someMethod($y);
-MyClass::myfunc(&$myvar);
-MyClass::myfunc($myvar);
-
-while (testfunc($var1, &$var2, $var3, &$var4) === false) {}
-
-sprintf('0%o', 0777 & $p);
-
-$foo(&$myvar);
-
-array_walk(array(), function () use (&$x) {});
-MyClass::myfunc(array(&$x, &$y));
+$var(&$x);
~~~~~~~~~~
-error:10:8
-error:13:15
-error:16:17
-error:19:24
-error:19:39
-error:23:6
+error:3:11
+error:6:16
+error:9:23
+error:12:6
diff --git a/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/function-declaration.lint-test b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/function-declaration.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/function-declaration.lint-test
@@ -0,0 +1,4 @@
+<?php
+function some_func(&$x) {}
+function & some_other_func($x) {}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/use.lint-test b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/use.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/call-time-pass-by-reference/use.lint-test
@@ -0,0 +1,3 @@
+<?php
+array_walk(array(), function () use (&$x) {});
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/dynamic-define/dynamic.lint-test b/src/lint/linter/xhpast/rules/__tests__/dynamic-define/dynamic.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/dynamic-define/dynamic.lint-test
@@ -0,0 +1,6 @@
+<?php
+define($pony, 'cute');
+define($pony, $cute);
+~~~~~~~~~~
+error:2:8
+error:3:8
diff --git a/src/lint/linter/xhpast/rules/__tests__/dynamic-define/dynamic-define.lint-test b/src/lint/linter/xhpast/rules/__tests__/dynamic-define/static.lint-test
rename from src/lint/linter/xhpast/rules/__tests__/dynamic-define/dynamic-define.lint-test
rename to src/lint/linter/xhpast/rules/__tests__/dynamic-define/static.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/dynamic-define/dynamic-define.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/dynamic-define/static.lint-test
@@ -1,9 +1,5 @@
<?php
-
define('PONY', 'cute');
-define($pony, 'cute');
define('PONY', $cute);
define($pony, $cute);
~~~~~~~~~~
-error:4:8 dynamic define
-error:6:8 dynamic define
diff --git a/src/lint/linter/xhpast/rules/__tests__/extract-use/extract-use.lint-test b/src/lint/linter/xhpast/rules/__tests__/extract-use/extract.lint-test
rename from src/lint/linter/xhpast/rules/__tests__/extract-use/extract-use.lint-test
rename to src/lint/linter/xhpast/rules/__tests__/extract-use/extract.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/extract-use/extract-use.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/extract-use/extract.lint-test
@@ -1,5 +1,4 @@
<?php
-
extract();
~~~~~~~~~~
-error:3:1
+error:2:1
diff --git a/src/lint/linter/xhpast/rules/__tests__/inner-function/closure.lint-test b/src/lint/linter/xhpast/rules/__tests__/inner-function/closure.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/inner-function/closure.lint-test
@@ -0,0 +1,5 @@
+<?php
+function some_func() {
+ function () {};
+}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/inner-function/inner-function.lint-test b/src/lint/linter/xhpast/rules/__tests__/inner-function/inner-function.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/inner-function/inner-function.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/inner-function/inner-function.lint-test
@@ -1,14 +1,8 @@
<?php
-
-function outer() {
- if (!function_exists('inner')) {
- function inner() {}
+function outer_func() {
+ if (!function_exists('inner_func')) {
+ function inner_func() {}
}
}
-
-// Closures are allowed.
-function my_func($foo) {
- function () {};
-}
~~~~~~~~~~
-warning:5:5
+warning:4:5
diff --git a/src/lint/linter/xhpast/rules/__tests__/logical-operators/boolean-operators.lint-test b/src/lint/linter/xhpast/rules/__tests__/logical-operators/boolean-operators.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/logical-operators/boolean-operators.lint-test
@@ -0,0 +1,4 @@
+<?php
+$x && $y;
+$x || $y;
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/logical-operators/logical-operators.lint-test b/src/lint/linter/xhpast/rules/__tests__/logical-operators/logical-operators.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/logical-operators/logical-operators.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/logical-operators/logical-operators.lint-test
@@ -1,22 +1,10 @@
<?php
-
-$x = false;
-$y = true;
-
$x and $y;
-$x && $y;
$x or $y;
-$x || $y;
~~~~~~~~~~
-advice:6:4
-advice:8:4
+advice:2:4
+advice:3:4
~~~~~~~~~~
<?php
-
-$x = false;
-$y = true;
-
$x && $y;
-$x && $y;
-$x || $y;
$x || $y;
diff --git a/src/lint/linter/xhpast/rules/__tests__/parse_str-use/one-parameter.lint-test b/src/lint/linter/xhpast/rules/__tests__/parse_str-use/one-parameter.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/parse_str-use/one-parameter.lint-test
@@ -0,0 +1,4 @@
+<?php
+parse_str('foo=bar');
+~~~~~~~~~~
+error:2:1
diff --git a/src/lint/linter/xhpast/rules/__tests__/parse_str-use/parse_str-use.lint-test b/src/lint/linter/xhpast/rules/__tests__/parse_str-use/two-parameters.lint-test
rename from src/lint/linter/xhpast/rules/__tests__/parse_str-use/parse_str-use.lint-test
rename to src/lint/linter/xhpast/rules/__tests__/parse_str-use/two-parameters.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/parse_str-use/parse_str-use.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/parse_str-use/two-parameters.lint-test
@@ -1,7 +1,4 @@
<?php
-
$params = array();
parse_str('foo=bar', $params);
-parse_str('foo=bar');
~~~~~~~~~~
-error:5:1
diff --git a/src/lint/linter/xhpast/rules/__tests__/php-close-tag/inline-html.lint-test b/src/lint/linter/xhpast/rules/__tests__/php-close-tag/inline-html.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/php-close-tag/inline-html.lint-test
@@ -0,0 +1,9 @@
+<html>
+<head></head>
+<body>
+<?php
+echo 'quack';
+?>
+</body>
+</html>
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/extract-use/extract-use.lint-test b/src/lint/linter/xhpast/rules/__tests__/php-close-tag/php.lint-test
rename from src/lint/linter/xhpast/rules/__tests__/extract-use/extract-use.lint-test
rename to src/lint/linter/xhpast/rules/__tests__/php-close-tag/php.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/extract-use/extract-use.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/php-close-tag/php.lint-test
@@ -1,5 +1,5 @@
<?php
-
-extract();
+echo 'quack';
+?>
~~~~~~~~~~
error:3:1
diff --git a/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/misuse.lint-test b/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/misuse.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/misuse.lint-test
@@ -0,0 +1,6 @@
+<?php
+preg_Quote('moo');
+preg_quote($bar);
+~~~~~~~~~~
+advice:2:1
+advice:3:1
diff --git a/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/preg_quote-misuse.lint-test b/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/preg_quote-misuse.lint-test
deleted file mode 100644
--- a/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/preg_quote-misuse.lint-test
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-function foo($bar) {
- preg_quote($bar);
- preg_quote($bar, '/');
- preg_Quote('moo');
- preg_quote('moo', '/');
-}
-~~~~~~~~~~
-advice:4:3 Wrong number of arguments to preg_quote()
-advice:6:3 Wrong number of arguments to preg_quote()
diff --git a/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/use.lint-test b/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/use.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/preg_quote-misuse/use.lint-test
@@ -0,0 +1,4 @@
+<?php
+preg_quote('moo', '/');
+preg_quote($bar, '/');
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/abstract.lint-test b/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/abstract.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/abstract.lint-test
@@ -0,0 +1,3 @@
+<?php
+abstract class B extends Phobject {}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/concrete-extensible.lint-test b/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/concrete-extensible.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/concrete-extensible.lint-test
@@ -0,0 +1,6 @@
+<?php
+/**
+ * @concrete-extensible
+ */
+class SomeClass {}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/final.lint-test b/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/final.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/final.lint-test
@@ -0,0 +1,3 @@
+<?php
+final class C extends Phobject {}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/ragged-classtree-edge.lint-test b/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/ragged-classtree-edge.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/ragged-classtree-edge.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/ragged-classtree-edge/ragged-classtree-edge.lint-test
@@ -1,12 +1,4 @@
<?php
-
-class A extends Phobject {}
-abstract class B extends Phobject {}
-final class C extends Phobject {}
-
-/**
- * @concrete-extensible
- */
-class D extends Phobject {}
+class SomeClass {}
~~~~~~~~~~
-disabled:3:7
+disabled:2:1
diff --git a/src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/nospacing.lint-test b/src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/nospacing.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/nospacing.lint-test
@@ -0,0 +1,5 @@
+<?php
+foo();
+bar();
+baz();
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/semicolon-spacing.lint-test b/src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/spacing.lint-test
rename from src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/semicolon-spacing.lint-test
rename to src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/spacing.lint-test
--- a/src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/semicolon-spacing.lint-test
+++ b/src/lint/linter/xhpast/rules/__tests__/semicolon-spacing/spacing.lint-test
@@ -1,16 +1,15 @@
<?php
-
-foo();
-bar() ;
+foo() ;
+bar() ;
baz()
;
~~~~~~~~~~
+advice:2:6
+advice:3:6
advice:4:6
-advice:5:6
~~~~~~~~~~
<?php
-
foo();
bar();
baz();
diff --git a/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/class.lint-test b/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/class.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/class.lint-test
@@ -0,0 +1,4 @@
+<?php
+class SomeClass {};
+~~~~~~~~~~
+advice:2:19
diff --git a/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/declare.lint-test b/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/declare.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/declare.lint-test
@@ -0,0 +1,9 @@
+<?php
+declare(ticks = 1);
+pcntl_signal(SIGTERM, 'ignore');
+pcntl_signal(SIGINT, 'ignore');
+
+function ignore($signo) {
+ return;
+}
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/empty.lint-test b/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/empty.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/empty.lint-test
@@ -0,0 +1,2 @@
+<?php
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/statement.lint-test b/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/statement.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/unnecessary-semicolon/statement.lint-test
@@ -0,0 +1,4 @@
+<?php
+echo 'quack';;
+~~~~~~~~~~
+advice:2:14
diff --git a/src/lint/linter/xhpast/rules/__tests__/variable-variable/nonvariable.lint-test b/src/lint/linter/xhpast/rules/__tests__/variable-variable/nonvariable.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/variable-variable/nonvariable.lint-test
@@ -0,0 +1,4 @@
+<?php
+$x;
+$obj->$bar;
+~~~~~~~~~~
diff --git a/src/lint/linter/xhpast/rules/__tests__/variable-variable/variable-variables.lint-test b/src/lint/linter/xhpast/rules/__tests__/variable-variable/variable-variables.lint-test
deleted file mode 100644
--- a/src/lint/linter/xhpast/rules/__tests__/variable-variable/variable-variables.lint-test
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-$$foo;
-$obj->$bar; // okay
-~~~~~~~~~~
-error:3:1
diff --git a/src/lint/linter/xhpast/rules/__tests__/variable-variable/variable.lint-test b/src/lint/linter/xhpast/rules/__tests__/variable-variable/variable.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/xhpast/rules/__tests__/variable-variable/variable.lint-test
@@ -0,0 +1,7 @@
+<?php
+$$x;
+$$$y;
+~~~~~~~~~~
+error:2:1
+error:3:1
+error:3:2

File Metadata

Mime Type
text/plain
Expires
Jul 20 2025, 8:55 PM (5 w, 5 d ago)
Storage Engine
amazon-s3
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
phabricator/secure/b4/z5/zaadxi2x5nictrjs
Default Alt Text
D14488.id35047.diff (62 KB)

Event Timeline