Skip to content

Commit 9bde4fd

Browse files
WyriHaximusclue
authored andcommitted
Update to require PHP 7.1+
1 parent 751374f commit 9bde4fd

12 files changed

+16
-132
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 25 deletions
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
@@ -52,23 +47,3 @@ jobs:
5247
- run: composer install
5348
- run: vendor/bin/phpunit --coverage-text
5449
- run: time php examples/91-benchmark-throughput.php
55-
56-
PHPUnit-hhvm:
57-
name: PHPUnit (HHVM)
58-
runs-on: ubuntu-22.04
59-
continue-on-error: true
60-
steps:
61-
- uses: actions/checkout@v4
62-
- run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM
63-
- name: Run hhvm composer.phar install
64-
uses: docker://hhvm/hhvm:3.30-lts-latest
65-
with:
66-
args: hhvm composer.phar install
67-
- name: Run hhvm vendor/bin/phpunit
68-
uses: docker://hhvm/hhvm:3.30-lts-latest
69-
with:
70-
args: hhvm vendor/bin/phpunit
71-
- name: Run time hhvm examples/91-benchmark-throughput.php
72-
uses: docker://hhvm/hhvm:3.30-lts-latest
73-
with:
74-
args: bash -c "time hhvm examples/91-benchmark-throughput.php"

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,8 @@ composer require react/stream:^3@dev
12171217
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
12181218

12191219
This project aims to run on any platform and thus does not require any PHP
1220-
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and HHVM.
1221-
It's *highly recommended to use PHP 7+* for this project due to its vast
1222-
performance improvements.
1220+
extensions and supports running on PHP 7.1 through current PHP 8+.
1221+
It's *highly recommended to use the latest supported PHP version* for this project.
12231222

12241223
## Tests
12251224

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
}
2727
],
2828
"require": {
29-
"php": ">=5.3.8",
29+
"php": ">=7.1",
3030
"react/event-loop": "^1.2",
3131
"evenement/evenement": "^3.0 || ^2.0 || ^1.0"
3232
},
3333
"require-dev": {
34-
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
34+
"phpunit/phpunit": "^9.6 || ^5.7",
3535
"clue/stream-filter": "~1.2"
3636
},
3737
"autoload": {

phpunit.xml.legacy

Lines changed: 1 addition & 1 deletion
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/5.7/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
77
colors="true">
88
<testsuites>

src/DuplexResourceStream.php

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct($stream, LoopInterface $loop = null, $readChunkSize
4646

4747
// ensure resource is opened for reading and wrting (fopen mode must contain "+")
4848
$meta = \stream_get_meta_data($stream);
49-
if (isset($meta['mode']) && $meta['mode'] !== '' && \strpos($meta['mode'], '+') === false) {
49+
if (\strpos($meta['mode'], '+') === false) {
5050
throw new InvalidArgumentException('Given stream resource is not opened in read and write mode');
5151
}
5252

@@ -59,14 +59,9 @@ public function __construct($stream, LoopInterface $loop = null, $readChunkSize
5959
// Use unbuffered read operations on the underlying stream resource.
6060
// Reading chunks from the stream may otherwise leave unread bytes in
6161
// PHP's stream buffers which some event loop implementations do not
62-
// trigger events on (edge triggered).
63-
// This does not affect the default event loop implementation (level
64-
// triggered), so we can ignore platforms not supporting this (HHVM).
65-
// Pipe streams (such as STDIN) do not seem to require this and legacy
66-
// PHP versions cause SEGFAULTs on unbuffered pipe streams, so skip this.
67-
if (\function_exists('stream_set_read_buffer') && !$this->isLegacyPipe($stream)) {
68-
\stream_set_read_buffer($stream, 0);
69-
}
62+
// trigger events on (edge triggered). This does not affect the default
63+
// event loop implementation (level triggered).
64+
\stream_set_read_buffer($stream, 0);
7065

7166
if ($buffer === null) {
7267
$buffer = new WritableResourceStream($stream, $loop);
@@ -200,28 +195,4 @@ public function handleData($stream)
200195
$this->close();
201196
}
202197
}
203-
204-
/**
205-
* Returns whether this is a pipe resource in a legacy environment
206-
*
207-
* This works around a legacy PHP bug (#61019) that was fixed in PHP 5.4.28+
208-
* and PHP 5.5.12+ and newer.
209-
*
210-
* @param resource $resource
211-
* @return bool
212-
* @link https://github.com/reactphp/child-process/issues/40
213-
*
214-
* @codeCoverageIgnore
215-
*/
216-
private function isLegacyPipe($resource)
217-
{
218-
if (\PHP_VERSION_ID < 50428 || (\PHP_VERSION_ID >= 50500 && \PHP_VERSION_ID < 50512)) {
219-
$meta = \stream_get_meta_data($resource);
220-
221-
if (isset($meta['stream_type']) && $meta['stream_type'] === 'STDIO') {
222-
return true;
223-
}
224-
}
225-
return false;
226-
}
227198
}

src/ReadableResourceStream.php

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct($stream, LoopInterface $loop = null, $readChunkSize
4848

4949
// ensure resource is opened for reading (fopen mode must contain "r" or "+")
5050
$meta = \stream_get_meta_data($stream);
51-
if (isset($meta['mode']) && $meta['mode'] !== '' && \strpos($meta['mode'], 'r') === \strpos($meta['mode'], '+')) {
51+
if (\strpos($meta['mode'], 'r') === \strpos($meta['mode'], '+')) {
5252
throw new InvalidArgumentException('Given stream resource is not opened in read mode');
5353
}
5454

@@ -61,14 +61,9 @@ public function __construct($stream, LoopInterface $loop = null, $readChunkSize
6161
// Use unbuffered read operations on the underlying stream resource.
6262
// Reading chunks from the stream may otherwise leave unread bytes in
6363
// PHP's stream buffers which some event loop implementations do not
64-
// trigger events on (edge triggered).
65-
// This does not affect the default event loop implementation (level
66-
// triggered), so we can ignore platforms not supporting this (HHVM).
67-
// Pipe streams (such as STDIN) do not seem to require this and legacy
68-
// PHP versions cause SEGFAULTs on unbuffered pipe streams, so skip this.
69-
if (\function_exists('stream_set_read_buffer') && !$this->isLegacyPipe($stream)) {
70-
\stream_set_read_buffer($stream, 0);
71-
}
64+
// trigger events on (edge triggered). This does not affect the default
65+
// event loop implementation (level triggered).
66+
\stream_set_read_buffer($stream, 0);
7267

7368
$this->stream = $stream;
7469
$this->loop = $loop ?: Loop::get();
@@ -152,28 +147,4 @@ public function handleData()
152147
$this->close();
153148
}
154149
}
155-
156-
/**
157-
* Returns whether this is a pipe resource in a legacy environment
158-
*
159-
* This works around a legacy PHP bug (#61019) that was fixed in PHP 5.4.28+
160-
* and PHP 5.5.12+ and newer.
161-
*
162-
* @param resource $resource
163-
* @return bool
164-
* @link https://github.com/reactphp/child-process/issues/40
165-
*
166-
* @codeCoverageIgnore
167-
*/
168-
private function isLegacyPipe($resource)
169-
{
170-
if (\PHP_VERSION_ID < 50428 || (\PHP_VERSION_ID >= 50500 && \PHP_VERSION_ID < 50512)) {
171-
$meta = \stream_get_meta_data($resource);
172-
173-
if (isset($meta['stream_type']) && $meta['stream_type'] === 'STDIO') {
174-
return true;
175-
}
176-
}
177-
return false;
178-
}
179150
}

src/WritableResourceStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct($stream, LoopInterface $loop = null, $writeBufferSof
3636

3737
// ensure resource is opened for writing (fopen mode must contain either of "waxc+")
3838
$meta = \stream_get_meta_data($stream);
39-
if (isset($meta['mode']) && $meta['mode'] !== '' && \strtr($meta['mode'], 'waxc+', '.....') === $meta['mode']) {
39+
if (\strtr($meta['mode'], 'waxc+', '.....') === $meta['mode']) {
4040
throw new \InvalidArgumentException('Given stream resource is not opened in write mode');
4141
}
4242

tests/DuplexResourceStreamIntegrationTest.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
use React\Stream\DuplexResourceStream;
77
use React\Stream\ReadableResourceStream;
88
use React\EventLoop\ExtEventLoop;
9-
use React\EventLoop\ExtLibeventLoop;
10-
use React\EventLoop\ExtLibevLoop;
119
use React\EventLoop\LoopInterface;
12-
use React\EventLoop\LibEventLoop;
13-
use React\EventLoop\LibEvLoop;
1410
use React\EventLoop\StreamSelectLoop;
1511

1612
class DuplexResourceStreamIntegrationTest extends TestCase
@@ -26,22 +22,6 @@ function () {
2622
return new StreamSelectLoop();
2723
}
2824
),
29-
array(
30-
function () {
31-
return function_exists('event_base_new');
32-
},
33-
function () {
34-
return class_exists('React\EventLoop\ExtLibeventLoop') ? new ExtLibeventLoop() : new LibEventLoop();
35-
}
36-
),
37-
array(
38-
function () {
39-
return class_exists('libev\EventLoop');
40-
},
41-
function () {
42-
return class_exists('React\EventLoop\ExtLibevLoop') ? new ExtLibevLoop() : new LibEvLoop();
43-
}
44-
),
4525
array(
4626
function () {
4727
return class_exists('EventBase') && class_exists('React\EventLoop\ExtEventLoop');

tests/DuplexResourceStreamTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ public function testConstructorThrowsExceptionOnInvalidStream()
6565
*/
6666
public function testConstructorThrowsExceptionOnWriteOnlyStream()
6767
{
68-
if (defined('HHVM_VERSION')) {
69-
$this->markTestSkipped('HHVM does not report fopen mode for STDOUT');
70-
}
71-
7268
$loop = $this->createLoopMock();
7369

7470
$this->setExpectedException('InvalidArgumentException');

tests/FunctionalInternetTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public function testUploadBiggerBlockSecure()
8787

8888
$stream = stream_socket_client('ssl://httpbin.org:443');
8989

90-
// PHP < 7.1.4 (and PHP < 7.0.18) suffers from a bug when writing big
91-
// chunks of data over TLS streams at once.
90+
// PHP < 7.1.4 suffers from a bug when writing big chunks of data over
91+
// TLS streams at once.
9292
// We work around this by limiting the write chunk size to 8192 bytes
9393
// here to also support older PHP versions.
9494
// See https://github.com/reactphp/socket/issues/105

0 commit comments

Comments
 (0)