Page MenuHomeSealhub

ArcanistInnerFunctionXHPASTLinterRule.php
No OneTemporary

Authored By
Unknown
Size
903 B
Referenced Files
None
Subscribers
None

ArcanistInnerFunctionXHPASTLinterRule.php

<?php
final class ArcanistInnerFunctionXHPASTLinterRule
extends ArcanistXHPASTLinterRule {
const ID = 59;
public function getLintName() {
return pht('Inner Functions');
}
public function getLintSeverity() {
return ArcanistLintSeverity::SEVERITY_WARNING;
}
public function process(XHPASTNode $root) {
$function_decls = $root->selectDescendantsOfType('n_FUNCTION_DECLARATION');
foreach ($function_decls as $function_declaration) {
$inner_functions = $function_declaration
->selectDescendantsOfType('n_FUNCTION_DECLARATION');
foreach ($inner_functions as $inner_function) {
if ($inner_function->getChildByIndex(2)->getTypeName() == 'n_EMPTY') {
// Anonymous closure.
continue;
}
$this->raiseLintAtNode(
$inner_function,
pht('Avoid the use of inner functions.'));
}
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Nov 27, 18:10 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1209188
Default Alt Text
ArcanistInnerFunctionXHPASTLinterRule.php (903 B)

Event Timeline