Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PHP 8.4+ support by avoiding implicitly nullable types #266

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
"require": {
"php": ">=7.1",
"nikic/fast-route": "^1.3",
"react/async": "^4 || ^3",
"react/http": "^1.10",
"react/promise": "^3",
"react/socket": "^1.14"
"react/async": "^4.3 || ^3",
"react/http": "^1.11",
"react/promise": "^3.2",
"react/socket": "^1.15"
},
"require-dev": {
"phpstan/phpstan": "1.10.47 || 1.4.10",
"phpunit/phpunit": "^9.6 || ^7.5",
"psr/container": "^2 || ^1",
"react/promise-timer": "^1.10"
"react/promise-timer": "^1.11"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct($loader = [])
}

/** @return mixed */
public function __invoke(ServerRequestInterface $request, callable $next = null)
public function __invoke(ServerRequestInterface $request, ?callable $next = null)
{
if ($next === null) {
// You don't want to end up here. This only happens if you use the
Expand All @@ -64,7 +64,7 @@ public function __invoke(ServerRequestInterface $request, callable $next = null)
*/
public function callable(string $class): callable
{
return function (ServerRequestInterface $request, callable $next = null) use ($class) {
return function (ServerRequestInterface $request, ?callable $next = null) use ($class) {
// Check `$class` references a valid class name that can be autoloaded
if (\is_array($this->container) && !\class_exists($class, true) && !interface_exists($class, false) && !trait_exists($class, false)) {
throw new \BadMethodCallException('Request handler class ' . $class . ' not found');
Expand Down
2 changes: 1 addition & 1 deletion src/Io/RouteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RouteHandler
/** @var Container */
private $container;

public function __construct(Container $container = null)
public function __construct(?Container $container = null)
{
$this->routeCollector = new RouteCollector(new RouteParser(), new RouteGenerator());
$this->errorHandler = new ErrorHandler();
Expand Down
4 changes: 2 additions & 2 deletions tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function testCallableReturnsCallableForClassWithNullDefaultViaAutowiringW
/** @var \stdClass|null|false */
private $data = false;

public function __construct(\stdClass $data = null)
public function __construct(?\stdClass $data = null)
{
$this->data = $data;
}
Expand Down Expand Up @@ -199,7 +199,7 @@ public function testCallableReturnsCallableForClassWithNullDefaultViaContainerCo
/** @var \stdClass|null|false */
private $data = false;

public function __construct(\stdClass $data = null)
public function __construct(?\stdClass $data = null)
{
$this->data = $data;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Io/RouteHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function testHandleRequestWithGetRequestReturnsResponseFromMatchingHandle
$controller = new class {
/** @var ?Response */
public static $response;
public function __construct(int $value = null)
public function __construct(?int $value = null)
{
assert($value === null);
}
Expand Down