From ee6e2a396fec887138ec253cad1a06a14906207a Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 12 May 2022 15:28:58 -0700 Subject: [PATCH] Fix some test suite stragglers with PHP 8.1 compatibility Summary: Ref T13588. This allows "arc unit --everything" to more or less run cleanly on PHP 8.1. Test Plan: Ran "arc unit --everything". Maniphest Tasks: T13588 Differential Revision: https://secure.phabricator.com/D21821 --- src/applications/calendar/parser/ics/PhutilICSWriter.php | 4 ++-- .../format/__tests__/PhabricatorFileStorageFormatTestCase.php | 4 ++++ src/applications/nuance/github/NuanceGitHubRawEvent.php | 2 +- .../markup/blockrule/PhutilRemarkupListBlockRule.php | 2 +- .../markup/markuprule/PhutilRemarkupDocumentLinkRule.php | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/applications/calendar/parser/ics/PhutilICSWriter.php b/src/applications/calendar/parser/ics/PhutilICSWriter.php index 8e7d06804c..c35008e079 100644 --- a/src/applications/calendar/parser/ics/PhutilICSWriter.php +++ b/src/applications/calendar/parser/ics/PhutilICSWriter.php @@ -184,14 +184,14 @@ final class PhutilICSWriter extends Phobject { } $name = $event->getName(); - if (strlen($name)) { + if (phutil_nonempty_string($name)) { $properties[] = $this->newTextProperty( 'SUMMARY', $name); } $description = $event->getDescription(); - if (strlen($description)) { + if (phutil_nonempty_string($description)) { $properties[] = $this->newTextProperty( 'DESCRIPTION', $description); diff --git a/src/applications/files/format/__tests__/PhabricatorFileStorageFormatTestCase.php b/src/applications/files/format/__tests__/PhabricatorFileStorageFormatTestCase.php index b3425ba313..bb850edc85 100644 --- a/src/applications/files/format/__tests__/PhabricatorFileStorageFormatTestCase.php +++ b/src/applications/files/format/__tests__/PhabricatorFileStorageFormatTestCase.php @@ -45,6 +45,10 @@ final class PhabricatorFileStorageFormatTestCase extends PhabricatorTestCase { } public function testAES256Storage() { + if (!function_exists('openssl_encrypt')) { + $this->assertSkipped(pht('No OpenSSL extension available.')); + } + $engine = new PhabricatorTestStorageEngine(); $key_name = 'test.abcd'; diff --git a/src/applications/nuance/github/NuanceGitHubRawEvent.php b/src/applications/nuance/github/NuanceGitHubRawEvent.php index b28a9222dc..8652dca9ad 100644 --- a/src/applications/nuance/github/NuanceGitHubRawEvent.php +++ b/src/applications/nuance/github/NuanceGitHubRawEvent.php @@ -164,7 +164,7 @@ final class NuanceGitHubRawEvent extends Phobject { $raw = $this->raw; $full = idxv($raw, array('repo', 'name')); - if (strlen($full)) { + if (phutil_nonempty_string($full)) { return $full; } diff --git a/src/infrastructure/markup/blockrule/PhutilRemarkupListBlockRule.php b/src/infrastructure/markup/blockrule/PhutilRemarkupListBlockRule.php index 5bdcab2b8f..b7d82edfef 100644 --- a/src/infrastructure/markup/blockrule/PhutilRemarkupListBlockRule.php +++ b/src/infrastructure/markup/blockrule/PhutilRemarkupListBlockRule.php @@ -446,7 +446,7 @@ final class PhutilRemarkupListBlockRule extends PhutilRemarkupBlockRule { } $start_attr = null; - if (ctype_digit($starts_at) && $starts_at > 1) { + if (ctype_digit(phutil_string_cast($starts_at)) && $starts_at > 1) { $start_attr = hsprintf(' start="%d"', $starts_at); } diff --git a/src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php b/src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php index 2170d9ae5e..ded57d4c77 100644 --- a/src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php +++ b/src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php @@ -46,7 +46,7 @@ final class PhutilRemarkupDocumentLinkRule extends PhutilRemarkupRule { $is_anchor = false; if (strncmp($link, '/', 1) == 0) { - $base = $engine->getConfig('uri.base'); + $base = phutil_string_cast($engine->getConfig('uri.base')); $base = rtrim($base, '/'); $link = $base.$link; } else if (strncmp($link, '#', 1) == 0) { @@ -134,7 +134,7 @@ final class PhutilRemarkupDocumentLinkRule extends PhutilRemarkupRule { public function markupDocumentLink(array $matches) { $uri = trim($matches[1]); - $name = trim(idx($matches, 2)); + $name = trim(idx($matches, 2, '')); if (!$this->isFlatText($uri)) { return $matches[0];