Skip to content

Commit

Permalink
Merge pull request #165 from antecedent/feature/php-8.4-fix-implicitl…
Browse files Browse the repository at this point in the history
…y-nullable-parameters

PHP 8.4 | Fix implicitly nullable parameters
  • Loading branch information
antecedent authored Sep 27, 2024
2 parents 41249a2 + 5af6ab2 commit b07d4fb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Patchwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function redefine($subject, callable $content)
return $handle;
}

function relay(array $args = null)
function relay(?array $args = null)
{
return CallRerouting\relay($args);
}
Expand Down
16 changes: 8 additions & 8 deletions src/CallRerouting.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function instantiate(@parameters) {
}
';

function connect($source, callable $target, Handle $handle = null, $partOfWildcard = false)
function connect($source, callable $target, ?Handle $handle = null, $partOfWildcard = false)
{
$source = translateIfLanguageConstruct($source);
$handle = $handle ?: new Handle;
Expand Down Expand Up @@ -109,7 +109,7 @@ function constitutesWildcard($source)
return strcspn($source, '*{,}') != strlen($source);
}

function applyWildcard($wildcard, callable $target, Handle $handle = null)
function applyWildcard($wildcard, callable $target, ?Handle $handle = null)
{
$handle = $handle ?: new Handle;
list($class, $method, $instance) = Utils\interpretCallable($wildcard);
Expand Down Expand Up @@ -178,7 +178,7 @@ function inPreprocessedFile($callable)
return $evaluated || !empty(State::$preprocessedFiles[$file]);
}

function connectFunction($function, callable $target, Handle $handle = null)
function connectFunction($function, callable $target, ?Handle $handle = null)
{
$handle = $handle ?: new Handle;
$routes = &State::$routes[null][$function];
Expand All @@ -187,7 +187,7 @@ function connectFunction($function, callable $target, Handle $handle = null)
return $handle;
}

function queueConnection($source, callable $target, Handle $handle = null)
function queueConnection($source, callable $target, ?Handle $handle = null)
{
$handle = $handle ?: new Handle;
$offset = Utils\append(State::$queue, [$source, $target, $handle]);
Expand All @@ -210,7 +210,7 @@ function deployQueue()
}
}

function connectMethod($function, callable $target, Handle $handle = null)
function connectMethod($function, callable $target, ?Handle $handle = null)
{
$handle = $handle ?: new Handle;
list($class, $method, $instance) = Utils\interpretCallable($function);
Expand All @@ -231,7 +231,7 @@ function connectMethod($function, callable $target, Handle $handle = null)
return $handle;
}

function connectInstantiation($class, callable $target, Handle $handle = null)
function connectInstantiation($class, callable $target, ?Handle $handle = null)
{
if (!Config\isNewKeywordRedefinable()) {
throw new Exceptions\NewKeywordNotRedefinable;
Expand Down Expand Up @@ -265,7 +265,7 @@ function dispatchTo(callable $target)
return call_user_func_array($target, Stack\top('args'));
}

function dispatch($class, $calledClass, $method, $frame, &$result, array $args = null)
function dispatch($class, $calledClass, $method, $frame, &$result, ?array $args = null)
{
$trace = debug_backtrace();
$isInternalStub = strpos($method, INTERNAL_REDEFINITION_NAMESPACE) === 0;
Expand Down Expand Up @@ -308,7 +308,7 @@ function dispatch($class, $calledClass, $method, $frame, &$result, array $args =
return $success;
}

function relay(array $args = null)
function relay(?array $args = null)
{
list($class, $method, $offset) = end(State::$routeStack);
$route = &State::$routes[$class][$method][$offset];
Expand Down
4 changes: 2 additions & 2 deletions src/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use Patchwork\Exceptions;

function push($offset, $calledClass, array $argsOverride = null)
function push($offset, $calledClass, ?array $argsOverride = null)
{
State::$items[] = [$offset, $calledClass, $argsOverride];
}
Expand All @@ -20,7 +20,7 @@ function pop()
array_pop(State::$items);
}

function pushFor($offset, $calledClass, $callback, array $argsOverride = null)
function pushFor($offset, $calledClass, $callback, ?array $argsOverride = null)
{
push($offset, $calledClass, $argsOverride);
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function wasRunAsConsoleApp()
);
}

function getParameterAndArgumentLists(\ReflectionMethod $reflection = null)
function getParameterAndArgumentLists(?\ReflectionMethod $reflection = null)
{
$parameters = [];
$arguments = [];
Expand Down

0 comments on commit b07d4fb

Please sign in to comment.