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

Fix some "expects string, string|false given" issues

Summary:
* /src/applications/config/check/PhabricatorPHPPreflightSetupCheck.php:87 Parameter #1 $string of function strlen expects string, string|false given.
* /src/applications/config/view/PhabricatorSetupIssueView.php:375 Parameter #2 $subject of function preg_match expects string, string|false given.
* /src/applications/config/view/PhabricatorSetupIssueView.php:382 Parameter #2 $subject of function preg_match expects string, string|false given.
* /src/applications/differential/storage/DifferentialHunk.php:229 Parameter #1 $string of function rtrim expects string, string|false given.
* /src/applications/diffusion/engine/DiffusionCommitHookEngine.php:985 Parameter #1 $string of function strlen expects string, string|false given.
* /src/applications/diffusion/engine/DiffusionCommitHookEngine.php:990 Parameter #1 $string of function strlen expects string, string|false given.
* /src/applications/diviner/workflow/DivinerGenerateWorkflow.php:59 Parameter #1 $root of class FileFinder constructor expects string, string|false given.
* /src/applications/drydock/management/DrydockManagementLeaseWorkflow.php:83 Parameter #1 $string of function phutil_json_decode expects string, string|false given.
* /src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php:78 Parameter #1 $string of function strlen expects string, string|false given.
* /src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php:79 Parameter #1 $string of function str_split expects string, string|false given.
* /src/applications/repository/storage/PhabricatorRepository.php:2263 Parameter #1 $string of function strlen expects string, string|false given.
* /src/applications/repository/storage/PhabricatorRepository.php:2270 Parameter #1 $string of function strlen expects string, string|false given.
* /src/infrastructure/log/PhabricatorSSHLog.php:38 Parameter #1 $string of function strlen expects string, string|false given.
* /src/infrastructure/log/PhabricatorSSHLog.php:39 Parameter #2 $string of function explode expects string, string|false given.
* /src/infrastructure/ssh/PhabricatorSSHWorkflow.php:104 Parameter #1 $string of function strlen expects string, string|false given.
* /src/infrastructure/ssh/PhabricatorSSHWorkflow.php:112 Parameter #2 $string of function explode expects string, string|false given.

Test Plan: Run static code analysis; read code.

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

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

+27 -19
+1 -1
src/applications/config/check/PhabricatorPHPPreflightSetupCheck.php
··· 84 84 } 85 85 86 86 $open_basedir = ini_get('open_basedir'); 87 - if (strlen($open_basedir)) { 87 + if ($open_basedir && strlen($open_basedir)) { 88 88 // If `open_basedir` is set, just fatal. It's technically possible for 89 89 // us to run with certain values of `open_basedir`, but: we can only 90 90 // raise fatal errors from preflight steps, so we'd have to do this check
+2 -2
src/applications/config/view/PhabricatorSetupIssueView.php
··· 372 372 $matches = null; 373 373 374 374 $ini_loc = null; 375 - if (preg_match($rex, $phpinfo, $matches)) { 375 + if ($phpinfo && preg_match($rex, $phpinfo, $matches)) { 376 376 $ini_loc = trim($matches[1]); 377 377 } 378 378 379 379 $rex = '@Additional \.ini files parsed\s*</td><td class="v">(.*?)</td>@i'; 380 380 381 381 $more_loc = array(); 382 - if (preg_match($rex, $phpinfo, $matches)) { 382 + if ($phpinfo && preg_match($rex, $phpinfo, $matches)) { 383 383 $more_loc = trim($matches[1]); 384 384 if ($more_loc == '(none)') { 385 385 $more_loc = array();
+1 -1
src/applications/differential/storage/DifferentialHunk.php
··· 225 225 } 226 226 227 227 if ($line[0] == '\\') { 228 - if ($use_next_newline) { 228 + if ($use_next_newline && $results) { 229 229 $results[last_key($results)] = rtrim(end($results), "\n"); 230 230 } 231 231 } else if (empty($include_map[$line[0]])) {
+2 -2
src/applications/diffusion/engine/DiffusionCommitHookEngine.php
··· 982 982 $key_name = getenv('HG_KEY'); 983 983 984 984 $key_old = getenv('HG_OLD'); 985 - if (!strlen($key_old)) { 985 + if (!$key_old || !strlen($key_old)) { 986 986 $key_old = null; 987 987 } 988 988 989 989 $key_new = getenv('HG_NEW'); 990 - if (!strlen($key_new)) { 990 + if (!$key_new || !strlen($key_new)) { 991 991 $key_new = null; 992 992 } 993 993
+7 -4
src/applications/diviner/workflow/DivinerGenerateWorkflow.php
··· 55 55 } else { 56 56 $cwd = getcwd(); 57 57 $this->log(pht('FINDING DOCUMENTATION BOOKS')); 58 + $books = array(); 58 59 59 - $books = id(new FileFinder($cwd)) 60 - ->withType('f') 61 - ->withSuffix('book') 62 - ->find(); 60 + if ($cwd) { 61 + $books = id(new FileFinder($cwd)) 62 + ->withType('f') 63 + ->withSuffix('book') 64 + ->find(); 65 + } 63 66 64 67 if (!$books) { 65 68 throw new PhutilArgumentUsageException(
+4 -3
src/applications/drydock/management/DrydockManagementLeaseWorkflow.php
··· 69 69 'number.')); 70 70 } 71 71 72 + $attributes = array(); 72 73 $attributes_file = $args->getArg('attributes'); 73 74 if (phutil_nonempty_string($attributes_file)) { 74 75 if ($attributes_file == '-') { ··· 80 81 $data = Filesystem::readFile($attributes_file); 81 82 } 82 83 83 - $attributes = phutil_json_decode($data); 84 - } else { 85 - $attributes = array(); 84 + if ($data) { 85 + $attributes = phutil_json_decode($data); 86 + } 86 87 } 87 88 88 89 $filter_identifiers = $args->getArg('blueprint');
+6 -2
src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php
··· 75 75 pht('Writing log, slowly...')); 76 76 77 77 $offset = 0; 78 - $total = strlen($content); 79 - $pieces = str_split($content, $rate); 78 + $total = 0; 79 + $pieces = array(); 80 + if ($content) { 81 + $total = strlen($content); 82 + $pieces = str_split($content, $rate); 83 + } 80 84 81 85 $bar = id(new PhutilConsoleProgressBar()) 82 86 ->setTotal($total);
+2 -2
src/applications/repository/storage/PhabricatorRepository.php
··· 2260 2260 ); 2261 2261 foreach ($git_env as $key) { 2262 2262 $value = getenv($key); 2263 - if (strlen($value)) { 2263 + if ($value && strlen($value)) { 2264 2264 $env[$key] = $value; 2265 2265 } 2266 2266 } 2267 2267 2268 2268 $key = 'GIT_PUSH_OPTION_COUNT'; 2269 2269 $git_count = getenv($key); 2270 - if (strlen($git_count)) { 2270 + if ($git_count && strlen($git_count)) { 2271 2271 $git_count = (int)$git_count; 2272 2272 $env[$key] = $git_count; 2273 2273 for ($ii = 0; $ii < $git_count; $ii++) {
+1 -1
src/infrastructure/log/PhabricatorSSHLog.php
··· 35 35 } 36 36 37 37 $client = getenv('SSH_CLIENT'); 38 - if (strlen($client)) { 38 + if ($client && strlen($client)) { 39 39 $remote_address = head(explode(' ', $client)); 40 40 $data['r'] = $remote_address; 41 41 }
+1 -1
src/infrastructure/ssh/PhabricatorSSHWorkflow.php
··· 101 101 102 102 public function getSSHRemoteAddress() { 103 103 $ssh_client = getenv('SSH_CLIENT'); 104 - if (!strlen($ssh_client)) { 104 + if (!$ssh_client || !strlen($ssh_client)) { 105 105 return null; 106 106 } 107 107