3
final class ArcanistControlStatementSpacingXHPASTLinterRule
4
extends ArcanistXHPASTLinterRule {
8
public function getLintName() {
9
return pht('Space After Control Statement');
12
public function getLintSeverity() {
13
return ArcanistLintSeverity::SEVERITY_WARNING;
16
public function process(XHPASTNode $root) {
17
foreach ($root->getTokens() as $id => $token) {
18
switch ($token->getTypeName()) {
26
$after = $token->getNonsemanticTokensAfter();
28
$this->raiseLintAtToken(
30
pht('Convention: put a space after control statements.'),
31
$token->getValue().' ');
32
} else if (count($after) === 1) {
33
$space = head($after);
35
// If we have an else clause with braces, $space may not be
36
// a single white space. e.g.,
40
// else // <- $space is not " " but "\n ".
43
// We just require it starts with either a whitespace or a newline.
44
if ($token->getTypeName() === 'T_ELSE' ||
45
$token->getTypeName() === 'T_DO') {
49
if ($space->isAnyWhitespace() && $space->getValue() !== ' ') {
50
$this->raiseLintAtToken(
52
pht('Convention: put a single space after control statements.'),