@@ -463,13 +463,7 @@ public function isOutputDisabled()
463
463
*/
464
464
public function getOutput ()
465
465
{
466
- if ($ this ->outputDisabled ) {
467
- throw new LogicException ('Output has been disabled. ' );
468
- }
469
-
470
- $ this ->requireProcessIsStarted (__FUNCTION__ );
471
-
472
- $ this ->readPipes (false , '\\' === DIRECTORY_SEPARATOR ? !$ this ->processInformation ['running ' ] : true );
466
+ $ this ->readPipesForOutput (__FUNCTION__ );
473
467
474
468
if (false === $ ret = stream_get_contents ($ this ->stdout , -1 , 0 )) {
475
469
return '' ;
@@ -491,11 +485,7 @@ public function getOutput()
491
485
*/
492
486
public function getIncrementalOutput ()
493
487
{
494
- if ($ this ->outputDisabled ) {
495
- throw new LogicException ('Output has been disabled. ' );
496
- }
497
-
498
- $ this ->requireProcessIsStarted (__FUNCTION__ );
488
+ $ this ->readPipesForOutput (__FUNCTION__ );
499
489
500
490
$ latest = stream_get_contents ($ this ->stdout , -1 , $ this ->incrementalOutputOffset );
501
491
$ this ->incrementalOutputOffset = ftell ($ this ->stdout );
@@ -531,13 +521,7 @@ public function clearOutput()
531
521
*/
532
522
public function getErrorOutput ()
533
523
{
534
- if ($ this ->outputDisabled ) {
535
- throw new LogicException ('Output has been disabled. ' );
536
- }
537
-
538
- $ this ->requireProcessIsStarted (__FUNCTION__ );
539
-
540
- $ this ->readPipes (false , '\\' === DIRECTORY_SEPARATOR ? !$ this ->processInformation ['running ' ] : true );
524
+ $ this ->readPipesForOutput (__FUNCTION__ );
541
525
542
526
if (false === $ ret = stream_get_contents ($ this ->stderr , -1 , 0 )) {
543
527
return '' ;
@@ -560,11 +544,7 @@ public function getErrorOutput()
560
544
*/
561
545
public function getIncrementalErrorOutput ()
562
546
{
563
- if ($ this ->outputDisabled ) {
564
- throw new LogicException ('Output has been disabled. ' );
565
- }
566
-
567
- $ this ->requireProcessIsStarted (__FUNCTION__ );
547
+ $ this ->readPipesForOutput (__FUNCTION__ );
568
548
569
549
$ latest = stream_get_contents ($ this ->stderr , -1 , $ this ->incrementalErrorOutputOffset );
570
550
$ this ->incrementalErrorOutputOffset = ftell ($ this ->stderr );
@@ -1328,6 +1308,24 @@ protected function isSigchildEnabled()
1328
1308
return self ::$ sigchild = false !== strpos (ob_get_clean (), '--enable-sigchild ' );
1329
1309
}
1330
1310
1311
+ /**
1312
+ * Reads pipes for the freshest output.
1313
+ *
1314
+ * @param $caller The name of the method that needs fresh outputs
1315
+ *
1316
+ * @throw LogicException in case output has been disabled or process is not started
1317
+ */
1318
+ private function readPipesForOutput ($ caller )
1319
+ {
1320
+ if ($ this ->outputDisabled ) {
1321
+ throw new LogicException ('Output has been disabled. ' );
1322
+ }
1323
+
1324
+ $ this ->requireProcessIsStarted ($ caller );
1325
+
1326
+ $ this ->updateStatus (false );
1327
+ }
1328
+
1331
1329
/**
1332
1330
* Validates and returns the filtered timeout.
1333
1331
*
0 commit comments