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
This commit is contained in:
Zach Borboa
2024-04-04 20:27:03 -04:00
committed by GitHub
parent 9bbbf4a3ff
commit b2657f5744
+6 -1
View File
@@ -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) {