diff --git a/src/applications/config/check/PhabricatorStorageSetupCheck.php b/src/applications/config/check/PhabricatorStorageSetupCheck.php --- a/src/applications/config/check/PhabricatorStorageSetupCheck.php +++ b/src/applications/config/check/PhabricatorStorageSetupCheck.php @@ -151,19 +151,19 @@ $how_many = 0; - if (strlen($access_key)) { + if (phutil_nonempty_string($access_key)) { $how_many++; } - if (strlen($secret_key)) { + if (phutil_nonempty_string($secret_key)) { $how_many++; } - if (strlen($region)) { + if (phutil_nonempty_string($region)) { $how_many++; } - if (strlen($endpoint)) { + if (phutil_nonempty_string($endpoint)) { $how_many++; } diff --git a/src/applications/files/engine/PhabricatorS3FileStorageEngine.php b/src/applications/files/engine/PhabricatorS3FileStorageEngine.php --- a/src/applications/files/engine/PhabricatorS3FileStorageEngine.php +++ b/src/applications/files/engine/PhabricatorS3FileStorageEngine.php @@ -31,11 +31,11 @@ $endpoint = PhabricatorEnv::getEnvConfig('amazon-s3.endpoint'); $region = PhabricatorEnv::getEnvConfig('amazon-s3.region'); - return (strlen($bucket) && - strlen($access_key) && - strlen($secret_key) && - strlen($endpoint) && - strlen($region)); + return phutil_nonempty_string($bucket) && + phutil_nonempty_string($access_key) && + phutil_nonempty_string($secret_key) && + phutil_nonempty_string($endpoint) && + phutil_nonempty_string($region); } @@ -57,7 +57,7 @@ $parts[] = 'phabricator'; $instance_name = PhabricatorEnv::getEnvConfig('cluster.instance'); - if (strlen($instance_name)) { + if (phutil_nonempty_string($instance_name)) { $parts[] = $instance_name; } diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php --- a/src/applications/files/storage/PhabricatorFile.php +++ b/src/applications/files/storage/PhabricatorFile.php @@ -856,7 +856,7 @@ // instance identity in the path allows us to distinguish between requests // originating from different instances but served through the same CDN. $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); - if (strlen($instance)) { + if (phutil_nonempty_string($instance)) { $parts[] = '@'.$instance; } @@ -903,7 +903,7 @@ $parts[] = 'xform'; $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); - if (strlen($instance)) { + if (phutil_nonempty_string($instance)) { $parts[] = '@'.$instance; } diff --git a/src/applications/metamta/engine/PhabricatorMailEmailEngine.php b/src/applications/metamta/engine/PhabricatorMailEmailEngine.php --- a/src/applications/metamta/engine/PhabricatorMailEmailEngine.php +++ b/src/applications/metamta/engine/PhabricatorMailEmailEngine.php @@ -507,7 +507,7 @@ public function newDefaultEmailAddress() { $raw_address = PhabricatorEnv::getEnvConfig('metamta.default-address'); - if (!strlen($raw_address)) { + if (!$raw_address) { $domain = $this->newMailDomain(); $raw_address = "noreply@{$domain}"; } @@ -527,7 +527,7 @@ private function newMailDomain() { $domain = PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain'); - if (strlen($domain)) { + if ($domain) { return $domain; } diff --git a/src/applications/notification/client/PhabricatorNotificationServerRef.php b/src/applications/notification/client/PhabricatorNotificationServerRef.php --- a/src/applications/notification/client/PhabricatorNotificationServerRef.php +++ b/src/applications/notification/client/PhabricatorNotificationServerRef.php @@ -152,7 +152,7 @@ ->setPath($full_path); $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); - if (strlen($instance)) { + if (phutil_nonempty_string($instance)) { $uri->replaceQueryParam('instance', $instance); } diff --git a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php --- a/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php +++ b/src/applications/repository/engine/PhabricatorRepositoryPullEngine.php @@ -238,7 +238,7 @@ $identifier = $repository->getPHID(); $instance = PhabricatorEnv::getEnvConfig('cluster.instance'); - if (strlen($instance)) { + if (phutil_nonempty_string($instance)) { $identifier = "{$identifier}:{$instance}"; } diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php --- a/src/applications/repository/storage/PhabricatorRepository.php +++ b/src/applications/repository/storage/PhabricatorRepository.php @@ -2480,7 +2480,8 @@ $has_https = false; } - $has_ssh = (bool)strlen(PhabricatorEnv::getEnvConfig('phd.user')); + $phd_user = PhabricatorEnv::getEnvConfig('phd.user'); + $has_ssh = phutil_nonempty_string($phd_user); $protocol_map = array( PhabricatorRepositoryURI::BUILTIN_PROTOCOL_SSH => $has_ssh, diff --git a/src/infrastructure/cluster/PhabricatorDatabaseRef.php b/src/infrastructure/cluster/PhabricatorDatabaseRef.php --- a/src/infrastructure/cluster/PhabricatorDatabaseRef.php +++ b/src/infrastructure/cluster/PhabricatorDatabaseRef.php @@ -229,7 +229,7 @@ $host = $this->getHost(); $port = $this->getPort(); - if (strlen($port)) { + if ($port) { return "{$host}:{$port}"; } diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php --- a/src/infrastructure/env/PhabricatorEnv.php +++ b/src/infrastructure/env/PhabricatorEnv.php @@ -125,7 +125,7 @@ // If an instance identifier is defined, write it into the environment so // it's available to subprocesses. $instance = self::getEnvConfig('cluster.instance'); - if (strlen($instance)) { + if (phutil_nonempty_string($instance)) { putenv('PHABRICATOR_INSTANCE='.$instance); $_ENV['PHABRICATOR_INSTANCE'] = $instance; } @@ -432,7 +432,7 @@ $uri = new PhutilURI($raw_uri); $host = $uri->getDomain(); - if (!strlen($host)) { + if (!$host) { return false; } @@ -455,7 +455,7 @@ $self_map = array(); foreach ($self_uris as $self_uri) { $host = id(new PhutilURI($self_uri))->getDomain(); - if (!strlen($host)) { + if (!$host) { continue; } @@ -661,7 +661,7 @@ public static function isValidLocalURIForLink($uri) { $uri = (string)$uri; - if (!strlen($uri)) { + if (!phutil_nonempty_string($uri)) { return false; } @@ -726,7 +726,7 @@ $uri = new PhutilURI($raw_uri); $proto = $uri->getProtocol(); - if (!strlen($proto)) { + if (!$proto) { throw new Exception( pht( 'URI "%s" is not a valid linkable resource. A valid linkable '. @@ -745,7 +745,7 @@ } $domain = $uri->getDomain(); - if (!strlen($domain)) { + if (!$domain) { throw new Exception( pht( 'URI "%s" is not a valid linkable resource. A valid linkable '. @@ -793,7 +793,7 @@ $uri = new PhutilURI($raw_uri); $proto = $uri->getProtocol(); - if (!strlen($proto)) { + if (!$proto) { throw new Exception( pht( 'URI "%s" is not a valid fetchable resource. A valid fetchable '. @@ -812,7 +812,7 @@ } $domain = $uri->getDomain(); - if (!strlen($domain)) { + if (!$domain) { throw new Exception( pht( 'URI "%s" is not a valid fetchable resource. A valid fetchable '. diff --git a/src/infrastructure/log/PhabricatorSSHLog.php b/src/infrastructure/log/PhabricatorSSHLog.php --- a/src/infrastructure/log/PhabricatorSSHLog.php +++ b/src/infrastructure/log/PhabricatorSSHLog.php @@ -24,7 +24,7 @@ ); $sudo_user = PhabricatorEnv::getEnvConfig('phd.user'); - if (strlen($sudo_user)) { + if (phutil_nonempty_string($sudo_user)) { $data['S'] = $sudo_user; }