Page MenuHomePhabricator

D14217.id34336.diff
No OneTemporary

D14217.id34336.diff

diff --git a/src/applications/drydock/logtype/DrydockLogType.php b/src/applications/drydock/logtype/DrydockLogType.php
--- a/src/applications/drydock/logtype/DrydockLogType.php
+++ b/src/applications/drydock/logtype/DrydockLogType.php
@@ -28,35 +28,7 @@
}
final public function getLogTypeConstant() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('LOGCONST');
- if ($const === false) {
- throw new Exception(
- pht(
- '"%s" class "%s" must define a "%s" property.',
- __CLASS__,
- get_class($this),
- 'LOGCONST'));
- }
-
- $limit = self::getLogTypeConstantByteLimit();
- if (!is_string($const) || (strlen($const) > $limit)) {
- throw new Exception(
- pht(
- '"%s" class "%s" has an invalid "%s" property. Field constants '.
- 'must be strings and no more than %s bytes in length.',
- __CLASS__,
- get_class($this),
- 'LOGCONST',
- new PhutilNumber($limit)));
- }
-
- return $const;
- }
-
- final private static function getLogTypeConstantByteLimit() {
- return 64;
+ return $this->getPhobjectClassConstant('LOGCONST', 64);
}
final public static function getAllLogTypes() {
diff --git a/src/applications/harbormaster/artifact/HarbormasterArtifact.php b/src/applications/harbormaster/artifact/HarbormasterArtifact.php
--- a/src/applications/harbormaster/artifact/HarbormasterArtifact.php
+++ b/src/applications/harbormaster/artifact/HarbormasterArtifact.php
@@ -43,35 +43,7 @@
}
final public function getArtifactConstant() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('ARTIFACTCONST');
- if ($const === false) {
- throw new Exception(
- pht(
- '"%s" class "%s" must define a "%s" property.',
- __CLASS__,
- get_class($this),
- 'ARTIFACTCONST'));
- }
-
- $limit = self::getArtifactConstantByteLimit();
- if (!is_string($const) || (strlen($const) > $limit)) {
- throw new Exception(
- pht(
- '"%s" class "%s" has an invalid "%s" property. Action constants '.
- 'must be strings and no more than %s bytes in length.',
- __CLASS__,
- get_class($this),
- 'ARTIFACTCONST',
- new PhutilNumber($limit)));
- }
-
- return $const;
- }
-
- final public static function getArtifactConstantByteLimit() {
- return 32;
+ return $this->getPhobjectClassConstant('ARTIFACTCONST', 32);
}
final public static function getAllArtifactTypes() {
diff --git a/src/applications/harbormaster/stepgroup/HarbormasterBuildStepGroup.php b/src/applications/harbormaster/stepgroup/HarbormasterBuildStepGroup.php
--- a/src/applications/harbormaster/stepgroup/HarbormasterBuildStepGroup.php
+++ b/src/applications/harbormaster/stepgroup/HarbormasterBuildStepGroup.php
@@ -14,19 +14,7 @@
}
final public function getGroupKey() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('GROUPKEY');
- if ($const === false) {
- throw new Exception(
- pht(
- '"%s" class "%s" must define a "%s" property.',
- __CLASS__,
- get_class($this),
- 'GROUPKEY'));
- }
-
- return $const;
+ return $this->getPhobjectClassConstant('GROUPKEY');
}
final public static function getAllGroups() {
diff --git a/src/applications/herald/action/HeraldAction.php b/src/applications/herald/action/HeraldAction.php
--- a/src/applications/herald/action/HeraldAction.php
+++ b/src/applications/herald/action/HeraldAction.php
@@ -122,35 +122,7 @@
}
final public function getActionConstant() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('ACTIONCONST');
- if ($const === false) {
- throw new Exception(
- pht(
- '"%s" class "%s" must define a "%s" property.',
- __CLASS__,
- get_class($this),
- 'ACTIONCONST'));
- }
-
- $limit = self::getActionConstantByteLimit();
- if (!is_string($const) || (strlen($const) > $limit)) {
- throw new Exception(
- pht(
- '"%s" class "%s" has an invalid "%s" property. Action constants '.
- 'must be strings and no more than %s bytes in length.',
- __CLASS__,
- get_class($this),
- 'ACTIONCONST',
- new PhutilNumber($limit)));
- }
-
- return $const;
- }
-
- final public static function getActionConstantByteLimit() {
- return 64;
+ return $this->getPhobjectClassConstant('ACTIONCONST', 64);
}
final public static function getAllActions() {
diff --git a/src/applications/herald/action/HeraldActionGroup.php b/src/applications/herald/action/HeraldActionGroup.php
--- a/src/applications/herald/action/HeraldActionGroup.php
+++ b/src/applications/herald/action/HeraldActionGroup.php
@@ -3,19 +3,7 @@
abstract class HeraldActionGroup extends HeraldGroup {
final public function getGroupKey() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('ACTIONGROUPKEY');
- if ($const === false) {
- throw new Exception(
- pht(
- '"%s" class "%s" must define a "%s" property.',
- __CLASS__,
- get_class($this),
- 'ACTIONGROUPKEY'));
- }
-
- return $const;
+ return $this->getPhobjectClassConstant('ACTIONGROUPKEY');
}
final public static function getAllActionGroups() {
diff --git a/src/applications/herald/field/HeraldField.php b/src/applications/herald/field/HeraldField.php
--- a/src/applications/herald/field/HeraldField.php
+++ b/src/applications/herald/field/HeraldField.php
@@ -169,31 +169,9 @@
}
final public function getFieldConstant() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('FIELDCONST');
- if ($const === false) {
- throw new Exception(
- pht(
- '"%s" class "%s" must define a "%s" property.',
- __CLASS__,
- get_class($this),
- 'FIELDCONST'));
- }
-
- $limit = self::getFieldConstantByteLimit();
- if (!is_string($const) || (strlen($const) > $limit)) {
- throw new Exception(
- pht(
- '"%s" class "%s" has an invalid "%s" property. Field constants '.
- 'must be strings and no more than %s bytes in length.',
- __CLASS__,
- get_class($this),
- 'FIELDCONST',
- new PhutilNumber($limit)));
- }
-
- return $const;
+ return $this->getPhobjectClassConstant(
+ 'FIELDCONST',
+ self::getFieldConstantByteLimit());
}
final public static function getFieldConstantByteLimit() {
diff --git a/src/applications/herald/field/HeraldFieldGroup.php b/src/applications/herald/field/HeraldFieldGroup.php
--- a/src/applications/herald/field/HeraldFieldGroup.php
+++ b/src/applications/herald/field/HeraldFieldGroup.php
@@ -3,19 +3,7 @@
abstract class HeraldFieldGroup extends HeraldGroup {
final public function getGroupKey() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('FIELDGROUPKEY');
- if ($const === false) {
- throw new Exception(
- pht(
- '"%s" class "%s" must define a "%s" property.',
- __CLASS__,
- get_class($this),
- 'FIELDGROUPKEY'));
- }
-
- return $const;
+ return $this->getPhobjectClassConstant('FIELDGROUPKEY');
}
final public static function getAllFieldGroups() {
diff --git a/src/applications/phid/type/PhabricatorPHIDType.php b/src/applications/phid/type/PhabricatorPHIDType.php
--- a/src/applications/phid/type/PhabricatorPHIDType.php
+++ b/src/applications/phid/type/PhabricatorPHIDType.php
@@ -3,17 +3,7 @@
abstract class PhabricatorPHIDType extends Phobject {
final public function getTypeConstant() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('TYPECONST');
- if ($const === false) {
- throw new Exception(
- pht(
- '%s class "%s" must define a %s property.',
- __CLASS__,
- get_class($this),
- 'TYPECONST'));
- }
+ $const = $this->getPhobjectClassConstant('TYPECONST');
if (!is_string($const) || !preg_match('/^[A-Z]{4}$/', $const)) {
throw new Exception(
diff --git a/src/applications/policy/capability/PhabricatorPolicyCapability.php b/src/applications/policy/capability/PhabricatorPolicyCapability.php
--- a/src/applications/policy/capability/PhabricatorPolicyCapability.php
+++ b/src/applications/policy/capability/PhabricatorPolicyCapability.php
@@ -15,29 +15,7 @@
* @return string Globally unique capability key.
*/
final public function getCapabilityKey() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('CAPABILITY');
- if ($const === false) {
- throw new Exception(
- pht(
- '%s class "%s" must define a %s property.',
- __CLASS__,
- get_class($this),
- 'CAPABILITY'));
- }
-
- if (!is_string($const)) {
- throw new Exception(
- pht(
- '%s class "%s" has an invalid %s property. '.
- 'Capability constants must be a string.',
- __CLASS__,
- get_class($this),
- 'CAPABILITY'));
- }
-
- return $const;
+ return $this->getPhobjectClassConstant('CAPABILITY');
}
diff --git a/src/infrastructure/edges/type/PhabricatorEdgeType.php b/src/infrastructure/edges/type/PhabricatorEdgeType.php
--- a/src/infrastructure/edges/type/PhabricatorEdgeType.php
+++ b/src/infrastructure/edges/type/PhabricatorEdgeType.php
@@ -12,17 +12,7 @@
abstract class PhabricatorEdgeType extends Phobject {
final public function getEdgeConstant() {
- $class = new ReflectionClass($this);
-
- $const = $class->getConstant('EDGECONST');
- if ($const === false) {
- throw new Exception(
- pht(
- '%s class "%s" must define an %s property.',
- __CLASS__,
- get_class($this),
- 'EDGECONST'));
- }
+ $const = $this->getPhobjectClassConstant('EDGECONST');
if (!is_int($const) || ($const <= 0)) {
throw new Exception(

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 21, 8:37 AM (1 d, 22 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7475970
Default Alt Text
D14217.id34336.diff (9 KB)

Event Timeline