@@ -463,13 +463,7 @@ public function isOutputDisabled()
463463 */
464464 public function getOutput ()
465465 {
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__ );
473467
474468 if (false === $ ret = stream_get_contents ($ this ->stdout , -1 , 0 )) {
475469 return '' ;
@@ -491,11 +485,7 @@ public function getOutput()
491485 */
492486 public function getIncrementalOutput ()
493487 {
494- if ($ this ->outputDisabled ) {
495- throw new LogicException ('Output has been disabled. ' );
496- }
497-
498- $ this ->requireProcessIsStarted (__FUNCTION__ );
488+ $ this ->readPipesForOutput (__FUNCTION__ );
499489
500490 $ latest = stream_get_contents ($ this ->stdout , -1 , $ this ->incrementalOutputOffset );
501491 $ this ->incrementalOutputOffset = ftell ($ this ->stdout );
@@ -531,13 +521,7 @@ public function clearOutput()
531521 */
532522 public function getErrorOutput ()
533523 {
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__ );
541525
542526 if (false === $ ret = stream_get_contents ($ this ->stderr , -1 , 0 )) {
543527 return '' ;
@@ -560,11 +544,7 @@ public function getErrorOutput()
560544 */
561545 public function getIncrementalErrorOutput ()
562546 {
563- if ($ this ->outputDisabled ) {
564- throw new LogicException ('Output has been disabled. ' );
565- }
566-
567- $ this ->requireProcessIsStarted (__FUNCTION__ );
547+ $ this ->readPipesForOutput (__FUNCTION__ );
568548
569549 $ latest = stream_get_contents ($ this ->stderr , -1 , $ this ->incrementalErrorOutputOffset );
570550 $ this ->incrementalErrorOutputOffset = ftell ($ this ->stderr );
@@ -1328,6 +1308,24 @@ protected function isSigchildEnabled()
13281308 return self ::$ sigchild = false !== strpos (ob_get_clean (), '--enable-sigchild ' );
13291309 }
13301310
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+
13311329 /**
13321330 * Validates and returns the filtered timeout.
13331331 *
0 commit comments