From 6e4947b55f09d58b80856fc1b54dccbffe3ecbc0 Mon Sep 17 00:00:00 2001 From: Aviv Eyal Date: Fri, 7 Jul 2023 02:02:12 -0700 Subject: [PATCH] Improve arc-browse for php 8.1 Summary: Ref T15064. Test Plan: ran some `arc browse` commands in php 8.1, got no exceptions. Reviewers: O1 Blessed Committers, valerio.bozzolan, Sten Reviewed By: O1 Blessed Committers, valerio.bozzolan, Sten Subscribers: Sten, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T15064 Differential Revision: https://we.phorge.it/D25339 --- .../query/ArcanistBrowseObjectNameURIHardpointQuery.php | 4 ++-- src/browse/workflow/ArcanistBrowseWorkflow.php | 4 ++-- src/ref/ArcanistRepositoryRef.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php b/src/browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php index c2ff847e..20b1d00e 100644 --- a/src/browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php +++ b/src/browse/query/ArcanistBrowseObjectNameURIHardpointQuery.php @@ -15,7 +15,7 @@ final class ArcanistBrowseObjectNameURIHardpointQuery $token_set = array(); foreach ($refs as $key => $ref) { $token = $ref->getToken(); - if (!strlen($token)) { + if (!phutil_nonempty_string($token)) { continue; } @@ -41,7 +41,7 @@ final class ArcanistBrowseObjectNameURIHardpointQuery continue; } - $uri = idx($object, 'uri'); + $uri = idx($object, 'uri', ''); if (!strlen($uri)) { continue; } diff --git a/src/browse/workflow/ArcanistBrowseWorkflow.php b/src/browse/workflow/ArcanistBrowseWorkflow.php index ffc41654..2198d50e 100644 --- a/src/browse/workflow/ArcanistBrowseWorkflow.php +++ b/src/browse/workflow/ArcanistBrowseWorkflow.php @@ -142,7 +142,7 @@ EOTEXT if ($many_hits) { foreach ($many_hits as $ref) { $token = $ref->getToken(); - if (strlen($token)) { + if (phutil_nonempty_string($token)) { $message = pht('Argument "%s" is ambiguous.', $token); } else { $message = pht('Default behavior is ambiguous.'); @@ -167,7 +167,7 @@ EOTEXT foreach ($many_hits as $ref) { $token_display = $ref->getToken(); - if (!strlen($token)) { + if (!phutil_nonempty_string($token)) { $token_display = pht(''); } diff --git a/src/ref/ArcanistRepositoryRef.php b/src/ref/ArcanistRepositoryRef.php index 38ef327b..c345c7d3 100644 --- a/src/ref/ArcanistRepositoryRef.php +++ b/src/ref/ArcanistRepositoryRef.php @@ -79,7 +79,7 @@ final class ArcanistRepositoryRef $params = $params + $defaults; - $uri_base = $this->browseURI; + $uri_base = coalesce($this->browseURI, ''); $uri_base = rtrim($uri_base, '/'); $uri_branch = phutil_escape_uri_path_component($params['branch']);