From a6cc6bba91a4593f4b9d3fd1fa6a002526712f80 Mon Sep 17 00:00:00 2001 From: Simon Frings Date: Mon, 26 Feb 2024 16:45:11 +0100 Subject: [PATCH] Update to require PHP 7.1+ --- .github/workflows/ci.yml | 21 --------------------- README.md | 3 +-- composer.json | 4 ++-- phpunit.xml.legacy | 2 +- src/Model/Message.php | 12 +----------- tests/FunctionalResolverTest.php | 3 --- tests/Query/TcpTransportExecutorTest.php | 8 ++------ 7 files changed, 7 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65fe5d47..7f3a7a1f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,11 +19,6 @@ jobs: - 7.3 - 7.2 - 7.1 - - 7.0 - - 5.6 - - 5.5 - - 5.4 - - 5.3 steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 @@ -50,19 +45,3 @@ jobs: ini-file: development - run: composer install - run: vendor/bin/phpunit --coverage-text - - PHPUnit-hhvm: - name: PHPUnit (HHVM) - runs-on: ubuntu-22.04 - continue-on-error: true - steps: - - uses: actions/checkout@v4 - - run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM - - name: Run hhvm composer.phar install - uses: docker://hhvm/hhvm:3.30-lts-latest - with: - args: hhvm composer.phar install - - name: Run hhvm vendor/bin/phpunit - uses: docker://hhvm/hhvm:3.30-lts-latest - with: - args: hhvm vendor/bin/phpunit diff --git a/README.md b/README.md index 2df8d224..73ea2fb6 100644 --- a/README.md +++ b/README.md @@ -424,8 +424,7 @@ composer require react/dns:^3@dev See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. This project aims to run on any platform and thus does not require any PHP -extensions and supports running on legacy PHP 5.3 through current PHP 8+ and -HHVM. +extensions and supports running on PHP 7.1 through current PHP 8+. It's *highly recommended to use the latest supported PHP version* for this project. ## Tests diff --git a/composer.json b/composer.json index de22b26f..263fba0f 100644 --- a/composer.json +++ b/composer.json @@ -26,13 +26,13 @@ } ], "require": { - "php": ">=5.3.0", + "php": ">=7.1", "react/cache": "^1.0 || ^0.6 || ^0.5", "react/event-loop": "^1.2", "react/promise": "^3.0 || ^2.7 || ^1.2.1" }, "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "phpunit/phpunit": "^9.6 || ^5.7", "react/async": "^4 || ^3 || ^2", "react/promise-timer": "^1.9" }, diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy index 89161168..a018d7ab 100644 --- a/phpunit.xml.legacy +++ b/phpunit.xml.legacy @@ -2,7 +2,7 @@ diff --git a/src/Model/Message.php b/src/Model/Message.php index bac2b10d..aafcce82 100644 --- a/src/Model/Message.php +++ b/src/Model/Message.php @@ -126,23 +126,13 @@ public static function createResponseWithAnswersForQuery(Query $query, array $an * DNS response messages can not guess the message ID to avoid possible * cache poisoning attacks. * - * The `random_int()` function is only available on PHP 7+ or when - * https://github.com/paragonie/random_compat is installed. As such, using - * the latest supported PHP version is highly recommended. This currently - * falls back to a less secure random number generator on older PHP versions - * in the hope that this system is properly protected against outside - * attackers, for example by using one of the common local DNS proxy stubs. - * * @return int * @see self::getId() * @codeCoverageIgnore */ private static function generateId() { - if (function_exists('random_int')) { - return random_int(0, 0xffff); - } - return mt_rand(0, 0xffff); + return random_int(0, 0xffff); } /** diff --git a/tests/FunctionalResolverTest.php b/tests/FunctionalResolverTest.php index 2e8690dd..3b707d90 100644 --- a/tests/FunctionalResolverTest.php +++ b/tests/FunctionalResolverTest.php @@ -123,9 +123,6 @@ public function testResolveInvalidRejects() public function testResolveCancelledRejectsImmediately() { - // max_nesting_level was set to 100 for PHP Versions < 5.4 which resulted in failing test for legacy PHP - ini_set('xdebug.max_nesting_level', 256); - $promise = $this->resolver->resolve('google.com'); $promise->cancel(); diff --git a/tests/Query/TcpTransportExecutorTest.php b/tests/Query/TcpTransportExecutorTest.php index 33dddacd..de05bcc2 100644 --- a/tests/Query/TcpTransportExecutorTest.php +++ b/tests/Query/TcpTransportExecutorTest.php @@ -117,10 +117,6 @@ public function testQueryRejectsIfMessageExceedsMaximumMessageSize() public function testQueryRejectsIfServerConnectionFails() { - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('HHVM reports different error message for invalid addresses'); - } - $loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock(); $loop->expects($this->never())->method('addWriteStream'); @@ -403,11 +399,11 @@ public function testQueryRejectsWhenClientKeepsSendingWhenServerClosesSocketWith restore_error_handler(); $this->assertNull($error); - // expect EPIPE (Broken pipe), except for macOS kernel race condition or legacy HHVM + // expect EPIPE (Broken pipe), except for macOS kernel race condition $this->setExpectedException( 'RuntimeException', 'Unable to send query to DNS server tcp://' . $address . ' (', - defined('SOCKET_EPIPE') && !defined('HHVM_VERSION') ? (PHP_OS !== 'Darwin' || $writePending ? SOCKET_EPIPE : SOCKET_EPROTOTYPE) : null + defined('SOCKET_EPIPE') ? (PHP_OS !== 'Darwin' || $writePending ? SOCKET_EPIPE : SOCKET_EPROTOTYPE) : null ); throw $exception; }