Page MenuHomePhabricator

D13541.id32721.diff
No OneTemporary

D13541.id32721.diff

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
Wed, Apr 23, 12:28 AM (2 d, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7225045
Default Alt Text
D13541.id32721.diff (1 KB)

Event Timeline