From 912acf195cfde5779447510e9e4266c3168f1112 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 12 Feb 2026 13:43:46 +0100 Subject: [PATCH] PHP 8.5: Tests: Fix tests in PhabricatorEnvTestCase Summary: Setting null as an array key is deprecated since PHP 8.5 per https://www.php.net/releases/8.5/en.php: "Using null as an array offset or when calling array_key_exists() is now deprecated. Use an empty string instead." According to https://web.archive.org/web/20171001040455/https://www.php.net/manual/en/language.types.array.php, `Null will be cast to the empty string, i.e. the key null will actually be stored under ""` at least since PHP 7.2, which we require. Closes T16495 Test Plan: Run `../arcanist/bin/arc unit ./src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php` in PHP 8.5 Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T16495 Differential Revision: https://we.phorge.it/D26748 --- .../env/__tests__/PhabricatorEnvTestCase.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php b/src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php index 59e925f15c..cc671d008a 100644 --- a/src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php +++ b/src/infrastructure/env/__tests__/PhabricatorEnvTestCase.php @@ -4,23 +4,23 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase { public function testLocalURIForLink() { $map = array( - '/' => true, - '/D123' => true, - '/path/to/something/' => true, - "/path/to/\nHeader: x" => false, - 'http://evil.com/' => false, - '//evil.com/evil/' => false, - 'javascript:lol' => false, - '' => false, - null => false, - '/\\evil.com' => false, + array('/', true), + array('/D123', true), + array('/path/to/something/', true), + array("/path/to/\nHeader: x", false), + array('http://evil.com/', false), + array('//evil.com/evil/', false), + array('javascript:lol', false), + array(null, false), + array('', false), + array('/\\evil.com', false), ); - foreach ($map as $uri => $expect) { + foreach ($map as $entry) { $this->assertEqual( - $expect, - PhabricatorEnv::isValidLocalURIForLink($uri), - pht('Valid local resource: %s', $uri)); + $entry[1], + PhabricatorEnv::isValidLocalURIForLink($entry[0]), + pht('Valid local resource: %s', $entry[0])); } } -- 2.51.2