Differential D19741 Diff 47163 src/lint/linter/xhpast/rules/ArcanistConstructorParenthesesXHPASTLinterRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/xhpast/rules/ArcanistConstructorParenthesesXHPASTLinterRule.php
| Show All 14 Lines | final class ArcanistConstructorParenthesesXHPASTLinterRule | ||||
| public function process(XHPASTNode $root) { | public function process(XHPASTNode $root) { | ||||
| $nodes = $root->selectDescendantsOfType('n_NEW'); | $nodes = $root->selectDescendantsOfType('n_NEW'); | ||||
| foreach ($nodes as $node) { | foreach ($nodes as $node) { | ||||
| $class = $node->getChildByIndex(0); | $class = $node->getChildByIndex(0); | ||||
| $params = $node->getChildByIndex(1); | $params = $node->getChildByIndex(1); | ||||
| if ($params->getTypeName() == 'n_EMPTY') { | if ($class->getTypeName() != 'n_CLASS_DECLARATION' && | ||||
| $params->getTypeName() == 'n_EMPTY') { | |||||
| $this->raiseLintAtNode( | $this->raiseLintAtNode( | ||||
| $class, | $class, | ||||
| pht('Use parentheses when invoking a constructor.'), | pht('Use parentheses when invoking a constructor.'), | ||||
| $class->getConcreteString().'()'); | $class->getConcreteString().'()'); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||