Skip to content

Commit c15a0d6

Browse files
committed
[3.x] Improve PHP 8.4+ support by avoiding implicitly nullable types
This changeset improves PHP 8.4+ support by avoiding implicitly nullable types as discussed in reactphp/promise#260. I'm planning to add native types to the public API and introduce PHPStan in follow-up PRs. Once merged, we should apply similar changes to all our upcoming v3 components. On top of this, we should backport similar changes to the v1 branch. Builds on top of reactphp#182, reactphp#222 and reactphp/promise#260
1 parent d9681b1 commit c15a0d6

5 files changed

+8
-8
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
"php": ">=7.1",
3030
"react/cache": "^1.0 || ^0.6 || ^0.5",
3131
"react/event-loop": "^1.2",
32-
"react/promise": "^3.0 || ^2.7 || ^1.2.1"
32+
"react/promise": "^3.2 || ^2.7 || ^1.2.1"
3333
},
3434
"require-dev": {
3535
"phpunit/phpunit": "^9.6 || ^7.5",
36-
"react/async": "^4 || ^3 || ^2",
37-
"react/promise-timer": "^1.9"
36+
"react/async": "^4.3 || ^3 || ^2",
37+
"react/promise-timer": "^1.11"
3838
},
3939
"autoload": {
4040
"psr-4": {

src/Query/TcpTransportExecutor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class TcpTransportExecutor implements ExecutorInterface
135135
* @param string $nameserver
136136
* @param ?LoopInterface $loop
137137
*/
138-
public function __construct($nameserver, LoopInterface $loop = null)
138+
public function __construct($nameserver, ?LoopInterface $loop = null)
139139
{
140140
if (\strpos($nameserver, '[') === false && \substr_count($nameserver, ':') >= 2 && \strpos($nameserver, '://') === false) {
141141
// several colons, but not enclosed in square brackets => enclose IPv6 address in square brackets

src/Query/TimeoutExecutor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class TimeoutExecutor implements ExecutorInterface
1212
private $loop;
1313
private $timeout;
1414

15-
public function __construct(ExecutorInterface $executor, $timeout, LoopInterface $loop = null)
15+
public function __construct(ExecutorInterface $executor, $timeout, ?LoopInterface $loop = null)
1616
{
1717
$this->executor = $executor;
1818
$this->loop = $loop ?: Loop::get();

src/Query/UdpTransportExecutor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ final class UdpTransportExecutor implements ExecutorInterface
9999
* @param string $nameserver
100100
* @param ?LoopInterface $loop
101101
*/
102-
public function __construct($nameserver, LoopInterface $loop = null)
102+
public function __construct($nameserver, ?LoopInterface $loop = null)
103103
{
104104
if (\strpos($nameserver, '[') === false && \substr_count($nameserver, ':') >= 2 && \strpos($nameserver, '://') === false) {
105105
// several colons, but not enclosed in square brackets => enclose IPv6 address in square brackets

src/Resolver/Factory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class Factory
3636
* @throws \InvalidArgumentException for invalid DNS server address
3737
* @throws \UnderflowException when given DNS Config object has an empty list of nameservers
3838
*/
39-
public function create($config, LoopInterface $loop = null)
39+
public function create($config, ?LoopInterface $loop = null)
4040
{
4141
$executor = $this->decorateHostsFileExecutor($this->createExecutor($config, $loop ?: Loop::get()));
4242

@@ -59,7 +59,7 @@ public function create($config, LoopInterface $loop = null)
5959
* @throws \InvalidArgumentException for invalid DNS server address
6060
* @throws \UnderflowException when given DNS Config object has an empty list of nameservers
6161
*/
62-
public function createCached($config, LoopInterface $loop = null, CacheInterface $cache = null)
62+
public function createCached($config, ?LoopInterface $loop = null, ?CacheInterface $cache = null)
6363
{
6464
// default to keeping maximum of 256 responses in cache unless explicitly given
6565
if (!($cache instanceof CacheInterface)) {

0 commit comments

Comments
 (0)