Skip to content

Commit d9681b1

Browse files
authored
Merge pull request reactphp#222 from SimonFrings/php7.1
Update to require PHP 7.1+
2 parents aa26641 + 8db0cb5 commit d9681b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+767
-800
lines changed

.github/workflows/ci.yml

-21
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ jobs:
1919
- 7.3
2020
- 7.2
2121
- 7.1
22-
- 7.0
23-
- 5.6
24-
- 5.5
25-
- 5.4
26-
- 5.3
2722
steps:
2823
- uses: actions/checkout@v4
2924
- uses: shivammathur/setup-php@v2
@@ -50,19 +45,3 @@ jobs:
5045
ini-file: development
5146
- run: composer install
5247
- run: vendor/bin/phpunit --coverage-text
53-
54-
PHPUnit-hhvm:
55-
name: PHPUnit (HHVM)
56-
runs-on: ubuntu-22.04
57-
continue-on-error: true
58-
steps:
59-
- uses: actions/checkout@v4
60-
- run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM
61-
- name: Run hhvm composer.phar install
62-
uses: docker://hhvm/hhvm:3.30-lts-latest
63-
with:
64-
args: hhvm composer.phar install
65-
- name: Run hhvm vendor/bin/phpunit
66-
uses: docker://hhvm/hhvm:3.30-lts-latest
67-
with:
68-
args: hhvm vendor/bin/phpunit

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,7 @@ composer require react/dns:^3@dev
424424
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
425425

426426
This project aims to run on any platform and thus does not require any PHP
427-
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
428-
HHVM.
427+
extensions and supports running on PHP 7.1 through current PHP 8+.
429428
It's *highly recommended to use the latest supported PHP version* for this project.
430429

431430
## Tests

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
}
2727
],
2828
"require": {
29-
"php": ">=5.3.0",
29+
"php": ">=7.1",
3030
"react/cache": "^1.0 || ^0.6 || ^0.5",
3131
"react/event-loop": "^1.2",
3232
"react/promise": "^3.0 || ^2.7 || ^1.2.1"
3333
},
3434
"require-dev": {
35-
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
35+
"phpunit/phpunit": "^9.6 || ^7.5",
3636
"react/async": "^4 || ^3 || ^2",
3737
"react/promise-timer": "^1.9"
3838
},

examples/01-one.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$factory = new Factory();
1414
$resolver = $factory->create($config);
1515

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

1818
$resolver->resolve($name)->then(function ($ip) use ($name) {
1919
echo 'IP for ' . $name . ': ' . $ip . PHP_EOL;

examples/02-concurrent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
$names = array_slice($argv, 1);
1717
if (!$names) {
18-
$names = array('google.com', 'www.google.com', 'gmail.com');
18+
$names = ['google.com', 'www.google.com', 'gmail.com'];
1919
}
2020

2121
foreach ($names as $name) {

examples/03-cached.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$factory = new Factory();
1515
$resolver = $factory->createCached($config);
1616

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

1919
$resolver->resolve($name)->then(function ($ip) use ($name) {
2020
echo 'IP for ' . $name . ': ' . $ip . PHP_EOL;

examples/11-all-ips.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$factory = new Factory();
1515
$resolver = $factory->create($config);
1616

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

1919
$resolver->resolveAll($name, Message::TYPE_A)->then(function (array $ips) use ($name) {
2020
echo 'IPv4 addresses for ' . $name . ': ' . implode(', ', $ips) . PHP_EOL;

examples/12-all-types.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
$factory = new Factory();
1717
$resolver = $factory->create($config);
1818

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

2222
$resolver->resolveAll($name, $type)->then(function (array $values) {
2323
var_dump($values);

examples/13-reverse-dns.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$factory = new Factory();
1515
$resolver = $factory->create($config);
1616

17-
$ip = isset($argv[1]) ? $argv[1] : '8.8.8.8';
17+
$ip = $argv[1] ?? '8.8.8.8';
1818

1919
if (@inet_pton($ip) === false) {
2020
exit('Error: Given argument is not a valid IP' . PHP_EOL);

examples/91-query-a-and-aaaa.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

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

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

1414
$ipv4Query = new Query($name, Message::TYPE_A, Message::CLASS_IN);
1515
$ipv6Query = new Query($name, Message::TYPE_AAAA, Message::CLASS_IN);

examples/92-query-any.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

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

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

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

phpunit.xml.legacy

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
77
colors="true">
88
<testsuites>

src/Config/Config.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function loadResolvConfBlocking($path = null)
8282
throw new RuntimeException('Unable to load resolv.conf file "' . $path . '"');
8383
}
8484

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

8888
$config = new self();
@@ -133,5 +133,5 @@ public static function loadWmicBlocking($command = null)
133133
return $config;
134134
}
135135

136-
public $nameservers = array();
136+
public $nameservers = [];
137137
}

src/Config/HostsFile.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function getIpsForHost($name)
9898
{
9999
$name = strtolower($name);
100100

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

134-
$names = array();
134+
$names = [];
135135
foreach (preg_split('/\r?\n/', $this->contents) as $line) {
136136
$parts = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
137137
$addr = (string) array_shift($parts);

src/Model/Message.php

+7-17
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,13 @@ public static function createResponseWithAnswersForQuery(Query $query, array $an
126126
* DNS response messages can not guess the message ID to avoid possible
127127
* cache poisoning attacks.
128128
*
129-
* The `random_int()` function is only available on PHP 7+ or when
130-
* https://github.com/paragonie/random_compat is installed. As such, using
131-
* the latest supported PHP version is highly recommended. This currently
132-
* falls back to a less secure random number generator on older PHP versions
133-
* in the hope that this system is properly protected against outside
134-
* attackers, for example by using one of the common local DNS proxy stubs.
135-
*
136129
* @return int
137130
* @see self::getId()
138131
* @codeCoverageIgnore
139132
*/
140133
private static function generateId()
141134
{
142-
if (function_exists('random_int')) {
143-
return random_int(0, 0xffff);
144-
}
145-
return mt_rand(0, 0xffff);
135+
return random_int(0, 0xffff);
146136
}
147137

148138
/**
@@ -200,31 +190,31 @@ private static function generateId()
200190
* An array of Query objects
201191
*
202192
* ```php
203-
* $questions = array(
193+
* $questions = [
204194
* new Query(
205195
* 'reactphp.org',
206196
* Message::TYPE_A,
207197
* Message::CLASS_IN
208198
* )
209-
* );
199+
* ];
210200
* ```
211201
*
212202
* @var Query[]
213203
*/
214-
public $questions = array();
204+
public $questions = [];
215205

216206
/**
217207
* @var Record[]
218208
*/
219-
public $answers = array();
209+
public $answers = [];
220210

221211
/**
222212
* @var Record[]
223213
*/
224-
public $authority = array();
214+
public $authority = [];
225215

226216
/**
227217
* @var Record[]
228218
*/
229-
public $additional = array();
219+
public $additional = [];
230220
}

0 commit comments

Comments
 (0)