8000 [Process] Use correct test for empty string in UnixPipes · webmozart/symfony@9e1ea4a · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e1ea4a

Browse files
whsromainneutron
authored andcommitted
[Process] Use correct test for empty string in UnixPipes
1 parent ea45769 commit 9e1ea4a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Symfony/Component/Process/ProcessPipes.php

Lines changed: 2 additions & 2 deletions
< EB5B th scope="col">Diff line change
Original file line numberDiff line number
@@ -313,11 +313,11 @@ private function readStreams($blocking, $close = false)
313313
$type = array_search($pipe, $this->pipes);
314314

315315
$data = '';
316-
while ($dataread = fread($pipe, self::CHUNK_SIZE)) {
316+
while ('' !== $dataread = (string) fread($pipe, self::CHUNK_SIZE)) {
317317
$data .= $dataread;
318318
}
319319

320-
if ($data) {
320+
if ('' !== $data) {
321321
$read[$type] = $data;
322322
}
323323

src/Symfony/Component/Process/Tests/AbstractProcessTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ public function testGetIncrementalOutput()
287287
}
288288
}
289289

290+
public function testZeroAsOutput(){
291+
$p = $this->getProcess('printf 0');
292+
$p->run();
293+
$this->assertSame('0', $p->getOutput());
294+
}
295+
290296
public function testExitCodeCommandFailed()
291297
{
292298
if (defined('PHP_WINDOWS_VERSION_BUILD')) {

0 commit comments

Comments
 (0)
0