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