Page MenuHomePhabricator

D13541.id.diff
No OneTemporary

D13541.id.diff

diff --git a/src/lint/linter/ArcanistXHPASTLinter.php b/src/lint/linter/ArcanistXHPASTLinter.php
--- a/src/lint/linter/ArcanistXHPASTLinter.php
+++ b/src/lint/linter/ArcanistXHPASTLinter.php
@@ -7,6 +7,9 @@
private $rules = array();
+ private $lintNameMap;
+ private $lintSeverityMap;
+
public function __construct() {
$this->rules = ArcanistXHPASTLinterRule::loadAllRules();
}
@@ -37,11 +40,25 @@
}
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() {
diff --git a/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php b/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php
--- a/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php
+++ b/src/lint/linter/xhpast/ArcanistXHPASTLinterRule.php
@@ -3,6 +3,7 @@
abstract class ArcanistXHPASTLinterRule extends Phobject {
private $linter = null;
+ private $lintID = null;
final public static function loadAllRules() {
$rules = array();
@@ -31,26 +32,31 @@
}
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();

File Metadata

Mime Type
text/plain
Expires
Mar 15 2025, 9:48 AM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7384944
Default Alt Text
D13541.id.diff (2 KB)

Event Timeline