@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use getPhobjectClassConstant() to access class constants

Summary: Ref T9494. Depends on D14216. Remove 10 copies of this code.

Test Plan: Ran `arc unit --everything`, browsed Config > Modules, clicked around Herald / etc.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9494

Differential Revision: https://secure.phabricator.com/D14217

+12 -196
+1 -29
src/applications/drydock/logtype/DrydockLogType.php
··· 28 28 } 29 29 30 30 final public function getLogTypeConstant() { 31 - $class = new ReflectionClass($this); 32 - 33 - $const = $class->getConstant('LOGCONST'); 34 - if ($const === false) { 35 - throw new Exception( 36 - pht( 37 - '"%s" class "%s" must define a "%s" property.', 38 - __CLASS__, 39 - get_class($this), 40 - 'LOGCONST')); 41 - } 42 - 43 - $limit = self::getLogTypeConstantByteLimit(); 44 - if (!is_string($const) || (strlen($const) > $limit)) { 45 - throw new Exception( 46 - pht( 47 - '"%s" class "%s" has an invalid "%s" property. Field constants '. 48 - 'must be strings and no more than %s bytes in length.', 49 - __CLASS__, 50 - get_class($this), 51 - 'LOGCONST', 52 - new PhutilNumber($limit))); 53 - } 54 - 55 - return $const; 56 - } 57 - 58 - final private static function getLogTypeConstantByteLimit() { 59 - return 64; 31 + return $this->getPhobjectClassConstant('LOGCONST', 64); 60 32 } 61 33 62 34 final public static function getAllLogTypes() {
+1 -29
src/applications/harbormaster/artifact/HarbormasterArtifact.php
··· 43 43 } 44 44 45 45 final public function getArtifactConstant() { 46 - $class = new ReflectionClass($this); 47 - 48 - $const = $class->getConstant('ARTIFACTCONST'); 49 - if ($const === false) { 50 - throw new Exception( 51 - pht( 52 - '"%s" class "%s" must define a "%s" property.', 53 - __CLASS__, 54 - get_class($this), 55 - 'ARTIFACTCONST')); 56 - } 57 - 58 - $limit = self::getArtifactConstantByteLimit(); 59 - if (!is_string($const) || (strlen($const) > $limit)) { 60 - throw new Exception( 61 - pht( 62 - '"%s" class "%s" has an invalid "%s" property. Action constants '. 63 - 'must be strings and no more than %s bytes in length.', 64 - __CLASS__, 65 - get_class($this), 66 - 'ARTIFACTCONST', 67 - new PhutilNumber($limit))); 68 - } 69 - 70 - return $const; 71 - } 72 - 73 - final public static function getArtifactConstantByteLimit() { 74 - return 32; 46 + return $this->getPhobjectClassConstant('ARTIFACTCONST', 32); 75 47 } 76 48 77 49 final public static function getAllArtifactTypes() {
+1 -13
src/applications/harbormaster/stepgroup/HarbormasterBuildStepGroup.php
··· 14 14 } 15 15 16 16 final public function getGroupKey() { 17 - $class = new ReflectionClass($this); 18 - 19 - $const = $class->getConstant('GROUPKEY'); 20 - if ($const === false) { 21 - throw new Exception( 22 - pht( 23 - '"%s" class "%s" must define a "%s" property.', 24 - __CLASS__, 25 - get_class($this), 26 - 'GROUPKEY')); 27 - } 28 - 29 - return $const; 17 + return $this->getPhobjectClassConstant('GROUPKEY'); 30 18 } 31 19 32 20 final public static function getAllGroups() {
+1 -29
src/applications/herald/action/HeraldAction.php
··· 122 122 } 123 123 124 124 final public function getActionConstant() { 125 - $class = new ReflectionClass($this); 126 - 127 - $const = $class->getConstant('ACTIONCONST'); 128 - if ($const === false) { 129 - throw new Exception( 130 - pht( 131 - '"%s" class "%s" must define a "%s" property.', 132 - __CLASS__, 133 - get_class($this), 134 - 'ACTIONCONST')); 135 - } 136 - 137 - $limit = self::getActionConstantByteLimit(); 138 - if (!is_string($const) || (strlen($const) > $limit)) { 139 - throw new Exception( 140 - pht( 141 - '"%s" class "%s" has an invalid "%s" property. Action constants '. 142 - 'must be strings and no more than %s bytes in length.', 143 - __CLASS__, 144 - get_class($this), 145 - 'ACTIONCONST', 146 - new PhutilNumber($limit))); 147 - } 148 - 149 - return $const; 150 - } 151 - 152 - final public static function getActionConstantByteLimit() { 153 - return 64; 125 + return $this->getPhobjectClassConstant('ACTIONCONST', 64); 154 126 } 155 127 156 128 final public static function getAllActions() {
+1 -13
src/applications/herald/action/HeraldActionGroup.php
··· 3 3 abstract class HeraldActionGroup extends HeraldGroup { 4 4 5 5 final public function getGroupKey() { 6 - $class = new ReflectionClass($this); 7 - 8 - $const = $class->getConstant('ACTIONGROUPKEY'); 9 - if ($const === false) { 10 - throw new Exception( 11 - pht( 12 - '"%s" class "%s" must define a "%s" property.', 13 - __CLASS__, 14 - get_class($this), 15 - 'ACTIONGROUPKEY')); 16 - } 17 - 18 - return $const; 6 + return $this->getPhobjectClassConstant('ACTIONGROUPKEY'); 19 7 } 20 8 21 9 final public static function getAllActionGroups() {
+3 -25
src/applications/herald/field/HeraldField.php
··· 169 169 } 170 170 171 171 final public function getFieldConstant() { 172 - $class = new ReflectionClass($this); 173 - 174 - $const = $class->getConstant('FIELDCONST'); 175 - if ($const === false) { 176 - throw new Exception( 177 - pht( 178 - '"%s" class "%s" must define a "%s" property.', 179 - __CLASS__, 180 - get_class($this), 181 - 'FIELDCONST')); 182 - } 183 - 184 - $limit = self::getFieldConstantByteLimit(); 185 - if (!is_string($const) || (strlen($const) > $limit)) { 186 - throw new Exception( 187 - pht( 188 - '"%s" class "%s" has an invalid "%s" property. Field constants '. 189 - 'must be strings and no more than %s bytes in length.', 190 - __CLASS__, 191 - get_class($this), 192 - 'FIELDCONST', 193 - new PhutilNumber($limit))); 194 - } 195 - 196 - return $const; 172 + return $this->getPhobjectClassConstant( 173 + 'FIELDCONST', 174 + self::getFieldConstantByteLimit()); 197 175 } 198 176 199 177 final public static function getFieldConstantByteLimit() {
+1 -13
src/applications/herald/field/HeraldFieldGroup.php
··· 3 3 abstract class HeraldFieldGroup extends HeraldGroup { 4 4 5 5 final public function getGroupKey() { 6 - $class = new ReflectionClass($this); 7 - 8 - $const = $class->getConstant('FIELDGROUPKEY'); 9 - if ($const === false) { 10 - throw new Exception( 11 - pht( 12 - '"%s" class "%s" must define a "%s" property.', 13 - __CLASS__, 14 - get_class($this), 15 - 'FIELDGROUPKEY')); 16 - } 17 - 18 - return $const; 6 + return $this->getPhobjectClassConstant('FIELDGROUPKEY'); 19 7 } 20 8 21 9 final public static function getAllFieldGroups() {
+1 -11
src/applications/phid/type/PhabricatorPHIDType.php
··· 3 3 abstract class PhabricatorPHIDType extends Phobject { 4 4 5 5 final public function getTypeConstant() { 6 - $class = new ReflectionClass($this); 7 - 8 - $const = $class->getConstant('TYPECONST'); 9 - if ($const === false) { 10 - throw new Exception( 11 - pht( 12 - '%s class "%s" must define a %s property.', 13 - __CLASS__, 14 - get_class($this), 15 - 'TYPECONST')); 16 - } 6 + $const = $this->getPhobjectClassConstant('TYPECONST'); 17 7 18 8 if (!is_string($const) || !preg_match('/^[A-Z]{4}$/', $const)) { 19 9 throw new Exception(
+1 -23
src/applications/policy/capability/PhabricatorPolicyCapability.php
··· 15 15 * @return string Globally unique capability key. 16 16 */ 17 17 final public function getCapabilityKey() { 18 - $class = new ReflectionClass($this); 19 - 20 - $const = $class->getConstant('CAPABILITY'); 21 - if ($const === false) { 22 - throw new Exception( 23 - pht( 24 - '%s class "%s" must define a %s property.', 25 - __CLASS__, 26 - get_class($this), 27 - 'CAPABILITY')); 28 - } 29 - 30 - if (!is_string($const)) { 31 - throw new Exception( 32 - pht( 33 - '%s class "%s" has an invalid %s property. '. 34 - 'Capability constants must be a string.', 35 - __CLASS__, 36 - get_class($this), 37 - 'CAPABILITY')); 38 - } 39 - 40 - return $const; 18 + return $this->getPhobjectClassConstant('CAPABILITY'); 41 19 } 42 20 43 21
+1 -11
src/infrastructure/edges/type/PhabricatorEdgeType.php
··· 12 12 abstract class PhabricatorEdgeType extends Phobject { 13 13 14 14 final public function getEdgeConstant() { 15 - $class = new ReflectionClass($this); 16 - 17 - $const = $class->getConstant('EDGECONST'); 18 - if ($const === false) { 19 - throw new Exception( 20 - pht( 21 - '%s class "%s" must define an %s property.', 22 - __CLASS__, 23 - get_class($this), 24 - 'EDGECONST')); 25 - } 15 + $const = $this->getPhobjectClassConstant('EDGECONST'); 26 16 27 17 if (!is_int($const) || ($const <= 0)) { 28 18 throw new Exception(