Page MenuHomeSealhub

ArcanistImplicitConstructorXHPASTLinterRule.php
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

ArcanistImplicitConstructorXHPASTLinterRule.php

<?php
final class ArcanistImplicitConstructorXHPASTLinterRule
extends ArcanistXHPASTLinterRule {
const ID = 10;
public function getLintName() {
return pht('Implicit Constructor');
}
public function process(XHPASTNode $root) {
$classes = $root->selectDescendantsOfType('n_CLASS_DECLARATION');
foreach ($classes as $class) {
$class_name = $class->getChildByIndex(1)->getConcreteString();
$methods = $class->selectDescendantsOfType('n_METHOD_DECLARATION');
foreach ($methods as $method) {
$method_name_token = $method->getChildByIndex(2);
$method_name = $method_name_token->getConcreteString();
if (strtolower($class_name) === strtolower($method_name)) {
$this->raiseLintAtNode(
$method_name_token,
pht(
'Name constructors %s explicitly. This method is a constructor '.
' because it has the same name as the class it is defined in.',
'__construct()'));
}
}
}
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Nov 27, 18:13 (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1218761
Default Alt Text
ArcanistImplicitConstructorXHPASTLinterRule.php (1 KB)

Event Timeline