private $rules = array();
+ private $lintNameMap;
+ private $lintSeverityMap;
+
public function __construct() {
$this->rules = ArcanistXHPASTLinterRule::loadAllRules();
}
}
public function getLintNameMap() {
- return mpull($this->rules, 'getLintName', 'getLintID');
+ if ($this->lintNameMap === null) {
+ $this->lintNameMap = mpull(
+ $this->rules,
+ 'getLintName',
+ 'getLintID');
+ }
+
+ return $this->lintNameMap;
}
public function getLintSeverityMap() {
- return mpull($this->rules, 'getLintSeverity', 'getLintID');
+ if ($this->lintSeverityMap === null) {
+ $this->lintSeverityMap = mpull(
+ $this->rules,
+ 'getLintSeverity',
+ 'getLintID');
+ }
+
+ return $this->lintSeverityMap;
}
public function getLinterConfigurationOptions() {
abstract class ArcanistXHPASTLinterRule extends Phobject {
private $linter = null;
+ private $lintID = null;
final public static function loadAllRules() {
$rules = array();
}
final public function getLintID() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('ID');
- if ($const === false) {
- throw new Exception(
- pht(
- '`%s` class `%s` must define an ID constant.',
- __CLASS__,
- get_class($this)));
- }
+ if ($this->lintID === null) {
+ $class = new ReflectionClass($this);
+
+ $const = $class->getConstant('ID');
+ if ($const === false) {
+ throw new Exception(
+ pht(
+ '`%s` class `%s` must define an ID constant.',
+ __CLASS__,
+ get_class($this)));
+ }
+
+ if (!is_int($const)) {
+ throw new Exception(
+ pht(
+ '`%s` class `%s` has an invalid ID constant. '.
+ 'ID must be an integer.',
+ __CLASS__,
+ get_class($this)));
+ }
- if (!is_int($const)) {
- throw new Exception(
- pht(
- '`%s` class `%s` has an invalid ID constant. ID must be an integer.',
- __CLASS__,
- get_class($this)));
+ $this->lintID = $const;
}
- return $const;
+ return $this->lintID;
}
abstract public function getLintName();