@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.

Explicitly cast int to string when expected by PHP functions

Summary: Avoid `Parameter $foo of function bar expects string, int[|string] given` output in static code analysis by explicitly casting to string when a return value is an int, or by passing a string by encapsulating an int with apostrophes.

Test Plan: Run static code analysis.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D26074

+15 -14
+1 -1
src/aphront/sink/AphrontHTTPSink.php
··· 33 33 * @return void 34 34 */ 35 35 final public function writeHTTPStatus($code, $message = '') { 36 - if (!preg_match('/^\d{3}$/', $code)) { 36 + if (!preg_match('/^\d{3}$/', (string)$code)) { 37 37 throw new Exception(pht("Malformed HTTP status code '%s'!", $code)); 38 38 } 39 39
+1 -1
src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php
··· 392 392 "%s\n", 393 393 pht('Starting Aphlict server in foreground...')); 394 394 } else { 395 - Filesystem::writeFile($this->getPIDPath(), getmypid()); 395 + Filesystem::writeFile($this->getPIDPath(), (string)getmypid()); 396 396 } 397 397 398 398 $command = $this->getStartCommand($this->getServerArgv());
+1 -1
src/applications/auth/factor/PhabricatorTOTPAuthFactor.php
··· 403 403 ((ord($hash[$offset + 3]) ) ); 404 404 405 405 $code = ($code % 1000000); 406 - $code = str_pad($code, 6, '0', STR_PAD_LEFT); 406 + $code = str_pad((string)$code, 6, '0', STR_PAD_LEFT); 407 407 408 408 return $code; 409 409 }
+2 -2
src/applications/config/check/PhabricatorWebServerSetupCheck.php
··· 43 43 ->replaceQueryParam($expect_key, $expect_value); 44 44 45 45 $self_future = id(new HTTPSFuture($base_uri)) 46 - ->addHeader('X-Setup-SelfCheck', 1) 46 + ->addHeader('X-Setup-SelfCheck', '1') 47 47 ->addHeader('Accept-Encoding', 'gzip') 48 48 ->setDisableContentDecoding(true) 49 49 ->setHTTPBasicAuthCredentials( ··· 56 56 $gzip_compressed = gzencode($gzip_uncompressed); 57 57 58 58 $gzip_future = id(new HTTPSFuture($base_uri)) 59 - ->addHeader('X-Setup-SelfCheck', 1) 59 + ->addHeader('X-Setup-SelfCheck', '1') 60 60 ->addHeader('Content-Encoding', 'gzip') 61 61 ->setMethod('POST') 62 62 ->setTimeout(5)
+1 -1
src/applications/differential/controller/DifferentialRevisionAffectedPathsController.php
··· 87 87 } 88 88 89 89 // Sort rows by path name. 90 - $rows = isort($rows, 3); 90 + $rows = isort($rows, '3'); 91 91 92 92 $table_view = id(new AphrontTableView($rows)) 93 93 ->setNoDataString(pht('This revision has no indexed affected paths.'))
+1 -1
src/applications/feed/PhabricatorFeedStoryPublisher.php
··· 321 321 // We're on a 32-bit machine. 322 322 if (function_exists('bcadd')) { 323 323 // Try to use the 'bc' extension. 324 - return bcadd(bcmul($time, bcpow(2, 32)), $rand); 324 + return bcadd(bcmul($time, bcpow('2', '32')), $rand); 325 325 } else { 326 326 // Do the math in MySQL. TODO: If we formalize a bc dependency, get 327 327 // rid of this.
+1 -1
src/applications/feed/storage/PhabricatorFeedStoryData.php
··· 45 45 // We're on a 32-bit machine. 46 46 if (function_exists('bcadd')) { 47 47 // Try to use the 'bc' extension. 48 - return bcdiv($this->chronologicalKey, bcpow(2, 32)); 48 + return bcdiv($this->chronologicalKey, bcpow('2', '32')); 49 49 } else { 50 50 // Do the math in MySQL. TODO: If we formalize a bc dependency, get 51 51 // rid of this.
+1 -1
src/applications/files/engine/PhabricatorLocalDiskFileStorageEngine.php
··· 47 47 // have one directory with a zillion files in it, since this is generally 48 48 // bad news. 49 49 do { 50 - $name = md5(mt_rand()); 50 + $name = md5((string)mt_rand()); 51 51 $name = preg_replace('/^(..)(..)(.*)$/', '\\1/\\2/\\3', $name); 52 52 if (!Filesystem::pathExists($root.'/'.$name)) { 53 53 break;
+1 -1
src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
··· 194 194 } 195 195 196 196 // Sort headers by name. 197 - $headers = isort($headers, 0); 197 + $headers = isort($headers, '0'); 198 198 199 199 foreach ($headers as $header) { 200 200 list($key, $value) = $header;
+1 -1
src/applications/phrequent/storage/PhrequentTimeBlock.php
··· 259 259 * @return list<pair<int, int>> Nonoverlapping time ranges. 260 260 */ 261 261 public static function mergeTimeRanges(array $ranges) { 262 - $ranges = isort($ranges, 0); 262 + $ranges = isort($ranges, '0'); 263 263 264 264 $result = array(); 265 265
+1
src/applications/search/engine/PhabricatorSearchNgramEngine.php
··· 35 35 36 36 $ngrams = array(); 37 37 foreach ($unique_tokens as $token => $ignored) { 38 + $token = (string)$token; 38 39 $token_v = phutil_utf8v($token); 39 40 $length = count($token_v); 40 41
+1 -1
src/applications/settings/panel/PhabricatorEmailPreferencesSettingsPanel.php
··· 120 120 } 121 121 122 122 // Sort them, then put "Common" at the top. 123 - $tag_groups = isort($tag_groups, 0); 123 + $tag_groups = isort($tag_groups, '0'); 124 124 if ($common_tags) { 125 125 array_unshift($tag_groups, array(pht('Common'), $common_tags)); 126 126 }
+1 -1
src/applications/xhprof/view/PhabricatorXHProfProfileSymbolView.php
··· 93 93 $data[$key]['wt'] / $flat[$symbol]['wt'], 94 94 ); 95 95 } 96 - $child_rows = isort($child_rows, 2); 96 + $child_rows = isort($child_rows, '2'); 97 97 $child_rows = array_reverse($child_rows); 98 98 $rows = array_merge( 99 99 $rows,
+1 -1
src/infrastructure/edges/query/PhabricatorEdgeQuery.php
··· 122 122 * use case. 123 123 * 124 124 * @param string $src_phid Source PHID. 125 - * @param string $edge_type Edge type constant. 125 + * @param string $edge_type Edge type constant. 126 126 * @return list<string> List of destination PHIDs. 127 127 */ 128 128 public static function loadDestinationPHIDs($src_phid, $edge_type) {