Skip to content

Commit

Permalink
Update to require PHP 7.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonFrings committed May 15, 2024
1 parent aa26641 commit a6cc6bb
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 46 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.legacy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
Expand Down
12 changes: 1 addition & 11 deletions src/Model/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
3 changes: 0 additions & 3 deletions tests/FunctionalResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
8 changes: 2 additions & 6 deletions tests/Query/TcpTransportExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a6cc6bb

Please sign in to comment.