Page MenuHomePhorge

ArcanistInnerFunctionXHPASTLinterRule.php
No OneTemporary

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
Mar 24 2025, 11:12 (7 w, 6 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1120355
Default Alt Text
ArcanistInnerFunctionXHPASTLinterRule.php (903 B)

Event Timeline