Differential D21024 Diff 50086 src/lint/linter/xhpast/rules/ArcanistImplodeArgumentOrderXHPASTLinterRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/xhpast/rules/ArcanistImplodeArgumentOrderXHPASTLinterRule.php
Show All 17 Lines | public function process(XHPASTNode $root) { | ||||
foreach ($implosions as $implosion) { | foreach ($implosions as $implosion) { | ||||
$parameters = $implosion->getChildOfType(1, 'n_CALL_PARAMETER_LIST'); | $parameters = $implosion->getChildOfType(1, 'n_CALL_PARAMETER_LIST'); | ||||
if (count($parameters->getChildren()) != 2) { | if (count($parameters->getChildren()) != 2) { | ||||
continue; | continue; | ||||
} | } | ||||
$parameter = $parameters->getChildByIndex(1); | $parameter = $parameters->getChildByIndex(1); | ||||
if (!$parameter->isStaticScalar()) { | |||||
// If the value is a static scalar, like a string literal, it's probably | |||||
// the glue. | |||||
$is_scalar = $parameter->isStaticScalar(); | |||||
// If the value is a constant, like "DIRECTORY_SEPARATOR", it's probably | |||||
// the glue. | |||||
$is_constant = ($parameter->getTypeName() === 'n_SYMBOL_NAME'); | |||||
$looks_like_glue = ($is_scalar || $is_constant); | |||||
if (!$looks_like_glue) { | |||||
continue; | continue; | ||||
} | } | ||||
$this->raiseLintAtNode( | $this->raiseLintAtNode( | ||||
$implosion, | $implosion, | ||||
pht( | pht( | ||||
'When calling "implode()", pass the "glue" argument first. (The '. | 'When calling "implode()", pass the "glue" argument first. (The '. | ||||
'other parameter order is deprecated in PHP 7.4 and raises a '. | 'other parameter order is deprecated in PHP 7.4 and raises a '. | ||||
'warning.)')); | 'warning.)')); | ||||
} | } | ||||
} | } | ||||
} | } |