Skip to content

Commit

Permalink
Merge pull request reactphp#222 from SimonFrings/php7.1
Browse files Browse the repository at this point in the history
Update to require PHP 7.1+
  • Loading branch information
WyriHaximus committed May 19, 2024
2 parents aa26641 + 8db0cb5 commit d9681b1
Show file tree
Hide file tree
Showing 46 changed files with 767 additions and 800 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 || ^7.5",
"react/async": "^4 || ^3 || ^2",
"react/promise-timer": "^1.9"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/01-one.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$factory = new Factory();
$resolver = $factory->create($config);

$name = isset($argv[1]) ? $argv[1] : 'www.google.com';
$name = $argv[1] ?? 'www.google.com';

$resolver->resolve($name)->then(function ($ip) use ($name) {
echo 'IP for ' . $name . ': ' . $ip . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion examples/02-concurrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

$names = array_slice($argv, 1);
if (!$names) {
$names = array('google.com', 'www.google.com', 'gmail.com');
$names = ['google.com', 'www.google.com', 'gmail.com'];
}

foreach ($names as $name) {
Expand Down
2 changes: 1 addition & 1 deletion examples/03-cached.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$factory = new Factory();
$resolver = $factory->createCached($config);

$name = isset($argv[1]) ? $argv[1] : 'www.google.com';
$name = $argv[1] ?? 'www.google.com';

$resolver->resolve($name)->then(function ($ip) use ($name) {
echo 'IP for ' . $name . ': ' . $ip . PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion examples/11-all-ips.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$factory = new Factory();
$resolver = $factory->create($config);

$name = isset($argv[1]) ? $argv[1] : 'www.google.com';
$name = $argv[1] ?? 'www.google.com';

$resolver->resolveAll($name, Message::TYPE_A)->then(function (array $ips) use ($name) {
echo 'IPv4 addresses for ' . $name . ': ' . implode(', ', $ips) . PHP_EOL;
Expand Down
4 changes: 2 additions & 2 deletions examples/12-all-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
$factory = new Factory();
$resolver = $factory->create($config);

$name = isset($argv[1]) ? $argv[1] : 'google.com';
$type = constant('React\Dns\Model\Message::TYPE_' . (isset($argv[2]) ? $argv[2] : 'TXT'));
$name = $argv[1] ?? 'google.com';
$type = constant('React\Dns\Model\Message::TYPE_' . ($argv[2] ?? 'TXT'));

$resolver->resolveAll($name, $type)->then(function (array $values) {
var_dump($values);
Expand Down
2 changes: 1 addition & 1 deletion examples/13-reverse-dns.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$factory = new Factory();
$resolver = $factory->create($config);

$ip = isset($argv[1]) ? $argv[1] : '8.8.8.8';
$ip = $argv[1] ?? '8.8.8.8';

if (@inet_pton($ip) === false) {
exit('Error: Given argument is not a valid IP' . PHP_EOL);
Expand Down
2 changes: 1 addition & 1 deletion examples/91-query-a-and-aaaa.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

$executor = new UdpTransportExecutor('8.8.8.8:53');

$name = isset($argv[1]) ? $argv[1] : 'www.google.com';
$name = $argv[1] ?? 'www.google.com';

$ipv4Query = new Query($name, Message::TYPE_A, Message::CLASS_IN);
$ipv6Query = new Query($name, Message::TYPE_AAAA, Message::CLASS_IN);
Expand Down
2 changes: 1 addition & 1 deletion examples/92-query-any.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

$executor = new TcpTransportExecutor('8.8.8.8:53');

$name = isset($argv[1]) ? $argv[1] : 'google.com';
$name = $argv[1] ?? 'google.com';

$any = new Query($name, Message::TYPE_ANY, Message::CLASS_IN);

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/7.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
Expand Down
4 changes: 2 additions & 2 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function loadResolvConfBlocking($path = null)
throw new RuntimeException('Unable to load resolv.conf file "' . $path . '"');
}

$matches = array();
$matches = [];
preg_match_all('/^nameserver\s+(\S+)\s*$/m', $contents, $matches);

$config = new self();
Expand Down Expand Up @@ -133,5 +133,5 @@ public static function loadWmicBlocking($command = null)
return $config;
}

public $nameservers = array();
public $nameservers = [];
}
6 changes: 3 additions & 3 deletions src/Config/HostsFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function getIpsForHost($name)
{
$name = strtolower($name);

$ips = array();
$ips = [];
foreach (preg_split('/\r?\n/', $this->contents) as $line) {
$parts = preg_split('/\s+/', $line);
$ip = array_shift($parts);
Expand Down Expand Up @@ -128,10 +128,10 @@ public function getHostsForIp($ip)
// check binary representation of IP to avoid string case and short notation
$ip = @inet_pton($ip);
if ($ip === false) {
return array();
return [];
}

$names = array();
$names = [];
foreach (preg_split('/\r?\n/', $this->contents) as $line) {
$parts = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
$addr = (string) array_shift($parts);
Expand Down
24 changes: 7 additions & 17 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 Expand Up @@ -200,31 +190,31 @@ private static function generateId()
* An array of Query objects
*
* ```php
* $questions = array(
* $questions = [
* new Query(
* 'reactphp.org',
* Message::TYPE_A,
* Message::CLASS_IN
* )
* );
* ];
* ```
*
* @var Query[]
*/
public $questions = array();
public $questions = [];

/**
* @var Record[]
*/
public $answers = array();
public $answers = [];

/**
* @var Record[]
*/
public $authority = array();
public $authority = [];

/**
* @var Record[]
*/
public $additional = array();
public $additional = [];
}
Loading

0 comments on commit d9681b1

Please sign in to comment.