From 8a895f0c92a7c4b10db95139bcff71bdf66d4d21 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 23 May 2020 18:55:06 +0200 Subject: [PATCH 1/2] Make PHP 8 green on Travis --- Pipes/UnixPipes.php | 2 +- Tests/ProcessTest.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Pipes/UnixPipes.php b/Pipes/UnixPipes.php index 1ebf2138..5784a315 100644 --- a/Pipes/UnixPipes.php +++ b/Pipes/UnixPipes.php @@ -118,7 +118,7 @@ public function readAndWrite($blocking, $close = false) $read[$type = array_search($pipe, $this->pipes, true)] = ''; do { - $data = fread($pipe, self::CHUNK_SIZE); + $data = @fread($pipe, self::CHUNK_SIZE); $read[$type] .= $data; } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1]))); diff --git a/Tests/ProcessTest.php b/Tests/ProcessTest.php index e5335282..2a588523 100644 --- a/Tests/ProcessTest.php +++ b/Tests/ProcessTest.php @@ -987,16 +987,23 @@ public function provideMethodsThatNeedATerminatedProcess() */ public function testWrongSignal($signal) { - $this->expectException('Symfony\Component\Process\Exception\RuntimeException'); if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('POSIX signals do not work on Windows'); } + if (\PHP_VERSION_ID < 80000 || \is_int($signal)) { + $this->expectException(RuntimeException::class); + } else { + $this->expectException('TypeError'); + } + $process = $this->getProcessForCode('sleep(38);'); $process->start(); try { $process->signal($signal); $this->fail('A RuntimeException must have been thrown'); + } catch (\TypeError $e) { + $process->stop(0); } catch (RuntimeException $e) { $process->stop(0); } From 3bc410c407cba1ef8a03ca46de69a08c8b04f54a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 23 May 2020 21:47:49 +0200 Subject: [PATCH 2/2] [Process] Fix failing test on php 8. --- Tests/ProcessTest.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Tests/ProcessTest.php b/Tests/ProcessTest.php index 5841e9c8..0f4d15f2 100644 --- a/Tests/ProcessTest.php +++ b/Tests/ProcessTest.php @@ -992,24 +992,16 @@ public function testWrongSignal() $this->markTestSkipped('POSIX signals do not work on Windows'); } - if (\PHP_VERSION_ID < 80000 || \is_int($signal)) { - $this->expectException(RuntimeException::class); - } else { - $this->expectException('TypeError'); - } + $this->expectException(RuntimeException::class); $process = $this->getProcessForCode('sleep(38);'); $process->start(); try { $process->signal(-4); $this->fail('A RuntimeException must have been thrown'); - } catch (\TypeError $e) { - $process->stop(0); - } catch (RuntimeException $e) { + } finally { $process->stop(0); } - - throw $e; } public function testDisableOutputDisablesTheOutput()