From b2657f5744c8ea7ab0c75f88bc115ac770bb72c2 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Thu, 4 Apr 2024 20:27:03 -0400 Subject: [PATCH] Fix CI: Use nullable type declaration (#859) * Use nullable type declaration Fixes warning: FILE: ./src/Curl/CaseInsensitiveArray.php ------------------------------------------------------------------------------------------------- FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE ------------------------------------------------------------------------------------------------- 45 | WARNING | Implicitly marking a parameter as nullable is deprecated since PHP 8.4. Update | | the type to be explicitly nullable instead. Found implicitly nullable parameter: | | $initial. | | (PHPCompatibility.FunctionDeclarations.RemovedImplicitlyNullableParam.Deprecated) ------------------------------------------------------------------------------------------------- * Remove parameter type to fix PHP 7.0 --- src/Curl/CaseInsensitiveArray.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Curl/CaseInsensitiveArray.php b/src/Curl/CaseInsensitiveArray.php index 54d1c12..3a4e1db 100644 --- a/src/Curl/CaseInsensitiveArray.php +++ b/src/Curl/CaseInsensitiveArray.php @@ -42,7 +42,12 @@ class CaseInsensitiveArray implements \ArrayAccess, \Countable, \Iterator * @param mixed[] $initial (optional) Existing array to convert. * @return CaseInsensitiveArray */ - public function __construct(array $initial = null) + // TODO: Use a nullable type declaration when supported versions >= PHP 7.1. + // Trying to use the nullable type declaration on PHP 7.0: + // public function __construct(?array $initial = null) + // results in: + // ParseError: syntax error, unexpected '?', expecting variable (T_VARIABLE) + public function __construct($initial = null) { if ($initial !== null) { foreach ($initial as $key => $value) {