Skip to content

Commit 8a57d6d

Browse files
committed
Improve PHP 8.4+ support by avoiding implicitly nullable types
1 parent a0b0158 commit 8a57d6d

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
"require": {
1414
"php": ">=7.1",
1515
"nikic/fast-route": "^1.3",
16-
"react/async": "^4 || ^3",
17-
"react/http": "^1.10",
18-
"react/promise": "^3",
19-
"react/socket": "^1.14"
16+
"react/async": "^4.3 || ^3",
17+
"react/http": "^1.11",
18+
"react/promise": "^3.2",
19+
"react/socket": "^1.15"
2020
},
2121
"require-dev": {
2222
"phpstan/phpstan": "1.10.47 || 1.4.10",
2323
"phpunit/phpunit": "^9.6 || ^7.5",
2424
"psr/container": "^2 || ^1",
25-
"react/promise-timer": "^1.10"
25+
"react/promise-timer": "^1.11"
2626
},
2727
"autoload": {
2828
"psr-4": {

src/Container.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct($loader = [])
4141
}
4242

4343
/** @return mixed */
44-
public function __invoke(ServerRequestInterface $request, callable $next = null)
44+
public function __invoke(ServerRequestInterface $request, ?callable $next = null)
4545
{
4646
if ($next === null) {
4747
// You don't want to end up here. This only happens if you use the
@@ -64,7 +64,7 @@ public function __invoke(ServerRequestInterface $request, callable $next = null)
6464
*/
6565
public function callable(string $class): callable
6666
{
67-
return function (ServerRequestInterface $request, callable $next = null) use ($class) {
67+
return function (ServerRequestInterface $request, ?callable $next = null) use ($class) {
6868
// Check `$class` references a valid class name that can be autoloaded
6969
if (\is_array($this->container) && !\class_exists($class, true) && !interface_exists($class, false) && !trait_exists($class, false)) {
7070
throw new \BadMethodCallException('Request handler class ' . $class . ' not found');

src/Io/RouteHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class RouteHandler
3030
/** @var Container */
3131
private $container;
3232

33-
public function __construct(Container $container = null)
33+
public function __construct(?Container $container = null)
3434
{
3535
$this->routeCollector = new RouteCollector(new RouteParser(), new RouteGenerator());
3636
$this->errorHandler = new ErrorHandler();

tests/ContainerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function testCallableReturnsCallableForClassWithNullDefaultViaAutowiringW
169169
/** @var \stdClass|null|false */
170170
private $data = false;
171171

172-
public function __construct(\stdClass $data = null)
172+
public function __construct(?\stdClass $data = null)
173173
{
174174
$this->data = $data;
175175
}
@@ -199,7 +199,7 @@ public function testCallableReturnsCallableForClassWithNullDefaultViaContainerCo
199199
/** @var \stdClass|null|false */
200200
private $data = false;
201201

202-
public function __construct(\stdClass $data = null)
202+
public function __construct(?\stdClass $data = null)
203203
{
204204
$this->data = $data;
205205
}

tests/Io/RouteHandlerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function testHandleRequestWithGetRequestReturnsResponseFromMatchingHandle
205205
$controller = new class {
206206
/** @var ?Response */
207207
public static $response;
208-
public function __construct(int $value = null)
208+
public function __construct(?int $value = null)
209209
{
210210
assert($value === null);
211211
}

0 commit comments

Comments
 (0)