Page MenuHomePhorge

ArcanistImplicitConstructorXHPASTLinterRule.php
No OneTemporary

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
Sun, Jan 19, 16:12 (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1120988
Default Alt Text
ArcanistImplicitConstructorXHPASTLinterRule.php (1 KB)

Event Timeline