Page MenuHomePhorge

ArcanistLanguageConstructParenthesesXHPASTLinterRule.php
No OneTemporary

ArcanistLanguageConstructParenthesesXHPASTLinterRule.php

<?php
final class ArcanistLanguageConstructParenthesesXHPASTLinterRule
extends ArcanistXHPASTLinterRule {
const ID = 46;
public function getLintName() {
return pht('Language Construct Parentheses');
}
public function getLintSeverity() {
return ArcanistLintSeverity::SEVERITY_WARNING;
}
public function process(XHPASTNode $root) {
$nodes = $root->selectDescendantsOfTypes(array(
'n_INCLUDE_FILE',
'n_ECHO_LIST',
));
foreach ($nodes as $node) {
$child = head($node->getChildren());
if ($child->getTypeName() === 'n_PARENTHETICAL_EXPRESSION') {
list($before, $after) = $child->getSurroundingNonsemanticTokens();
$replace = preg_replace(
'/^\((.*)\)$/',
'$1',
$child->getConcreteString());
if (!$before) {
$replace = ' '.$replace;
}
$this->raiseLintAtNode(
$child,
pht('Language constructs do not require parentheses.'),
$replace);
}
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Mar 24, 01:45 (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1121989
Default Alt Text
ArcanistLanguageConstructParenthesesXHPASTLinterRule.php (1 KB)

Event Timeline