From 2e19efd6c171d8d61dd133dd3b9d588dbf01acc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Sat, 4 Dec 2021 14:08:56 +0100 Subject: [PATCH] Support PHP 8.1 --- composer.json | 2 +- phpunit.xml.dist | 3 ++- src/Config/HostsFile.php | 4 ++-- src/Protocol/BinaryDumper.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 28482f50..0126343f 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "react/cache": "^1.0 || ^0.6 || ^0.5", "react/event-loop": "^1.2", "react/promise": "^3.0 || ^2.7 || ^1.2.1", - "react/promise-timer": "^1.2" + "react/promise-timer": "^1.8" }, "require-dev": { "clue/block-react": "^1.2", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fa88e7e0..93a36f6b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,8 +4,9 @@ + convertDeprecationsToExceptions="true"> ./tests/ diff --git a/src/Config/HostsFile.php b/src/Config/HostsFile.php index c9e66da7..1060231a 100644 --- a/src/Config/HostsFile.php +++ b/src/Config/HostsFile.php @@ -133,8 +133,8 @@ public function getHostsForIp($ip) $names = array(); foreach (preg_split('/\r?\n/', $this->contents) as $line) { - $parts = preg_split('/\s+/', $line, null, PREG_SPLIT_NO_EMPTY); - $addr = array_shift($parts); + $parts = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY); + $addr = (string) array_shift($parts); // remove IPv6 zone ID (`fe80::1%lo0` => `fe80:1`) if (strpos($addr, ':') !== false && ($pos = strpos($addr, '%')) !== false) { diff --git a/src/Protocol/BinaryDumper.php b/src/Protocol/BinaryDumper.php index 83861cf0..6f4030f6 100644 --- a/src/Protocol/BinaryDumper.php +++ b/src/Protocol/BinaryDumper.php @@ -146,7 +146,7 @@ private function recordsToBinary(array $records) if ($opt === Message::OPT_TCP_KEEPALIVE && $value !== null) { $value = \pack('n', round($value * 10)); } - $binary .= \pack('n*', $opt, \strlen($value)) . $value; + $binary .= \pack('n*', $opt, \strlen((string) $value)) . $value; } break; default: