@@ -375,7 +375,11 @@ public function getOutput()
375
375
376
376
$ this ->readPipes (false , '\\' === DIRECTORY_SEPARATOR ? !$ this ->processInformation ['running ' ] : true );
377
377
378
- return $ this ->stdout ;
378
+ if (false === $ ret = stream_get_contents ($ this ->stdout , -1 , 0 )) {
379
+ return '' ;
380
+ }
381
+
382
+ return $ ret ;
379
383
}
380
384
381
385
/**
@@ -392,16 +396,13 @@ public function getIncrementalOutput()
392
396
{
393
397
$ this ->requireProcessIsStarted (__FUNCTION__ );
394
398
395
- $ data = $ this ->getOutput ();
396
-
397
- $ latest = substr ($ data , $ this ->incrementalOutputOffset );
399
+ $ latest = stream_get_contents ($ this ->stdout , -1 , $ this ->incrementalOutputOffset );
400
+ $ this ->incrementalOutputOffset = ftell ($ this ->stdout );
398
401
399
402
if (false === $ latest ) {
400
403
return '' ;
401
404
}
402
405
403
- $ this ->incrementalOutputOffset = strlen ($ data );
404
-
405
406
return $ latest ;
406
407
}
407
408
@@ -418,7 +419,11 @@ public function getErrorOutput()
418
419
419
420
$ this ->readPipes (false , '\\' === DIRECTORY_SEPARATOR ? !$ this ->processInformation ['running ' ] : true );
420
421
421
- return $ this ->stderr ;
422
+ if (false === $ ret = stream_get_contents ($ this ->stderr , -1 , 0 )) {
423
+ return '' ;
424
+ }
425
+
426
+ return $ ret ;
422
427
}
423
428
424
429
/**
@@ -436,16 +441,13 @@ public function getIncrementalErrorOutput()
436
441
{
437
442
$ this ->requireProcessIsStarted (__FUNCTION__ );
438
443
439
- $ data = $ this ->getErrorOutput ();
440
-
441
- $ latest = substr ($ data , $ this ->incrementalErrorOutputOffset );
444
+ $ latest = stream_get_contents ($ this ->stderr , -1 , $ this ->incrementalErrorOutputOffset );
445
+ $ this ->incrementalErrorOutputOffset = ftell ($ this ->stderr );
442
446
443
447
if (false === $ latest ) {
444
448
return '' ;
445
449
}
446
450
447
- $ this ->incrementalErrorOutputOffset = strlen ($ data );
448
-
449
451
return $ latest ;
450
452
}
451
453
@@ -663,21 +665,29 @@ public function stop($timeout = 10, $signal = null)
663
665
/**
664
666
* Adds a line to the STDOUT stream.
665
667
*
668
+ * @internal
669
+ *
666
670
* @param string $line The line to append
667
671
*/
668
672
public function addOutput ($ line )
669
673
{
670
- $ this ->stdout .= $ line ;
674
+ fseek ($ this ->stdout , 0 , SEEK_END );
675
+ fwrite ($ this ->stdout , $ line );
676
+ fseek ($ this ->stdout , $ this ->incrementalOutputOffset );
671
677
}
672
678
673
679
/**
674
680
* Adds a line to the STDERR stream.
675
681
*
682
+ * @internal
683
+ *
676
684
* @param string $line The line to append
677
685
*/
678
686
public function addErrorOutput ($ line )
679
687
{
680
- $ this ->stderr .= $ line ;
688
+ fseek ($ this ->stderr , 0 , SEEK_END );
689
+ fwrite ($ this ->stderr , $ line );
690
+ fseek ($ this ->stderr , $ this ->incrementalErrorOutputOffset );
681
691
}
682
692
683
693
/**
@@ -1123,8 +1133,8 @@ private function resetProcessData()
1123
1133
$ this ->exitcode = null ;
1124
1134
$ this ->fallbackStatus = array ();
1125
1135
$ this ->processInformation = null ;
1126
- $ this ->stdout = null ;
1127
- $ this ->stderr = null ;
1136
+ $ this ->stdout = fopen ( ' php://temp/maxmemory: ' .( 1024 * 1024 ), ' wb+ ' ) ;
1137
+ $ this ->stderr = fopen ( ' php://temp/maxmemory: ' .( 1024 * 1024 ), ' wb+ ' ) ;
1128
1138
$ this ->process = null ;
1129
1139
$ this ->latestSignal = null ;
1130
1140
$ this ->status = self ::STATUS_READY ;
0 commit comments