1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-09 16:32:39 +01:00

(stable) Promote 2019 Week 43

This commit is contained in:
epriestley 2019-10-26 08:34:17 -07:00
commit 79ec6e4459
4 changed files with 72 additions and 0 deletions

View file

@ -185,6 +185,8 @@ phutil_register_library_map(array(
'ArcanistImplicitFallthroughXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistImplicitFallthroughXHPASTLinterRuleTestCase.php',
'ArcanistImplicitVisibilityXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistImplicitVisibilityXHPASTLinterRule.php',
'ArcanistImplicitVisibilityXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistImplicitVisibilityXHPASTLinterRuleTestCase.php',
'ArcanistImplodeArgumentOrderXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistImplodeArgumentOrderXHPASTLinterRule.php',
'ArcanistImplodeArgumentOrderXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistImplodeArgumentOrderXHPASTLinterRuleTestCase.php',
'ArcanistInlineHTMLXHPASTLinterRule' => 'lint/linter/ArcanistInlineHTMLXHPASTLinterRule.php',
'ArcanistInlineHTMLXHPASTLinterRuleTestCase' => 'lint/linter/xhpast/rules/__tests__/ArcanistInlineHTMLXHPASTLinterRuleTestCase.php',
'ArcanistInnerFunctionXHPASTLinterRule' => 'lint/linter/xhpast/rules/ArcanistInnerFunctionXHPASTLinterRule.php',
@ -608,6 +610,8 @@ phutil_register_library_map(array(
'ArcanistImplicitFallthroughXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistImplicitVisibilityXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistImplicitVisibilityXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistImplodeArgumentOrderXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistImplodeArgumentOrderXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistInlineHTMLXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',
'ArcanistInlineHTMLXHPASTLinterRuleTestCase' => 'ArcanistXHPASTLinterRuleTestCase',
'ArcanistInnerFunctionXHPASTLinterRule' => 'ArcanistXHPASTLinterRule',

View file

@ -0,0 +1,39 @@
<?php
final class ArcanistImplodeArgumentOrderXHPASTLinterRule
extends ArcanistXHPASTLinterRule {
const ID = 129;
public function getLintName() {
return pht('Implode With Glue First');
}
public function getLintSeverity() {
return ArcanistLintSeverity::SEVERITY_ERROR;
}
public function process(XHPASTNode $root) {
$implosions = $this->getFunctionCalls($root, array('implode'));
foreach ($implosions as $implosion) {
$parameters = $implosion->getChildOfType(1, 'n_CALL_PARAMETER_LIST');
if (count($parameters->getChildren()) != 2) {
continue;
}
$parameter = $parameters->getChildByIndex(1);
if (!$parameter->isStaticScalar()) {
continue;
}
$this->raiseLintAtNode(
$implosion,
pht(
'When calling "implode()", pass the "glue" argument first. (The '.
'other parameter order is deprecated in PHP 7.4 and raises a '.
'warning.)'));
}
}
}

View file

@ -0,0 +1,11 @@
<?php
final class ArcanistImplodeArgumentOrderXHPASTLinterRuleTestCase
extends ArcanistXHPASTLinterRuleTestCase {
public function testLinter() {
$this->executeTestsInDirectory(
dirname(__FILE__).'/implode-argument-order/');
}
}

View file

@ -0,0 +1,18 @@
<?php
// This is the correct argument order.
implode(' ', $x);
// This is the legacy argument order which warns in PHP 7.4+.
implode($x, ' ');
// No warning: we can't statically tell which one is the glue.
implode($x, $y);
// No warning: these are likely wrong, but not a glue order problem.
implode();
implode($x);
implode($x, $y, $z);
~~~~~~~~~~
error:7:1:XHP129:Implode With Glue First