Differential D19741 Diff 47163 src/lint/linter/xhpast/rules/ArcanistSelfClassReferenceXHPASTLinterRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/lint/linter/xhpast/rules/ArcanistSelfClassReferenceXHPASTLinterRule.php
| Show All 11 Lines | final class ArcanistSelfClassReferenceXHPASTLinterRule | ||||
| public function getLintSeverity() { | public function getLintSeverity() { | ||||
| return ArcanistLintSeverity::SEVERITY_WARNING; | return ArcanistLintSeverity::SEVERITY_WARNING; | ||||
| } | } | ||||
| public function process(XHPASTNode $root) { | public function process(XHPASTNode $root) { | ||||
| $class_declarations = $root->selectDescendantsOfType('n_CLASS_DECLARATION'); | $class_declarations = $root->selectDescendantsOfType('n_CLASS_DECLARATION'); | ||||
| foreach ($class_declarations as $class_declaration) { | foreach ($class_declarations as $class_declaration) { | ||||
| if ($class_declaration->getChildByIndex(1)->getTypeName() == 'n_EMPTY') { | |||||
| continue; | |||||
| } | |||||
| $class_name = $class_declaration | $class_name = $class_declaration | ||||
| ->getChildOfType(1, 'n_CLASS_NAME') | ->getChildOfType(1, 'n_CLASS_NAME') | ||||
| ->getConcreteString(); | ->getConcreteString(); | ||||
| $instantiations = $class_declaration | $instantiations = $class_declaration | ||||
| ->selectDescendantsOfType('n_NEW'); | ->selectDescendantsOfType('n_NEW'); | ||||
| foreach ($instantiations as $instantiation) { | foreach ($instantiations as $instantiation) { | ||||
| $type = $instantiation->getChildByIndex(0); | $type = $instantiation->getChildByIndex(0); | ||||
| Show All 18 Lines | |||||