Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / process / Pipes / AbstractPipes.php
index 4c67d5b82c31a24113ef8a4223d9f12f1cc50d70..e5e26866afd936641cc1dc8d1da8c204ee858f4d 100644 (file)
@@ -20,21 +20,21 @@ use Symfony\Component\Process\Exception\InvalidArgumentException;
  */
 abstract class AbstractPipes implements PipesInterface
 {
-    /** @var array */
     public $pipes = array();
 
-    /** @var string */
     private $inputBuffer = '';
-    /** @var resource|scalar|\Iterator|null */
     private $input;
-    /** @var bool */
     private $blocked = true;
+    private $lastError;
 
+    /**
+     * @param resource|string|int|float|bool|\Iterator|null $input
+     */
     public function __construct($input)
     {
-        if (is_resource($input) || $input instanceof \Iterator) {
+        if (\is_resource($input) || $input instanceof \Iterator) {
             $this->input = $input;
-        } elseif (is_string($input)) {
+        } elseif (\is_string($input)) {
             $this->inputBuffer = $input;
         } else {
             $this->inputBuffer = (string) $input;
@@ -59,10 +59,11 @@ abstract class AbstractPipes implements PipesInterface
      */
     protected function hasSystemCallBeenInterrupted()
     {
-        $lastError = error_get_last();
+        $lastError = $this->lastError;
+        $this->lastError = null;
 
         // stream_select returns false when the `select` system call is interrupted by an incoming signal
-        return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call');
+        return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
     }
 
     /**
@@ -77,7 +78,7 @@ abstract class AbstractPipes implements PipesInterface
         foreach ($this->pipes as $pipe) {
             stream_set_blocking($pipe, 0);
         }
-        if (is_resource($this->input)) {
+        if (\is_resource($this->input)) {
             stream_set_blocking($this->input, 0);
         }
 
@@ -99,12 +100,12 @@ abstract class AbstractPipes implements PipesInterface
         if ($input instanceof \Iterator) {
             if (!$input->valid()) {
                 $input = null;
-            } elseif (is_resource($input = $input->current())) {
+            } elseif (\is_resource($input = $input->current())) {
                 stream_set_blocking($input, 0);
             } elseif (!isset($this->inputBuffer[0])) {
-                if (!is_string($input)) {
+                if (!\is_string($input)) {
                     if (!is_scalar($input)) {
-                        throw new InvalidArgumentException(sprintf('%s yielded a value of type "%s", but only scalars and stream resources are supported', get_class($this->input), gettype($input)));
+                        throw new InvalidArgumentException(sprintf('%s yielded a value of type "%s", but only scalars and stream resources are supported', \get_class($this->input), \gettype($input)));
                     }
                     $input = (string) $input;
                 }
@@ -120,7 +121,7 @@ abstract class AbstractPipes implements PipesInterface
         $w = array($this->pipes[0]);
 
         // let's have a look if something changed in streams
-        if (false === $n = @stream_select($r, $w, $e, 0, 0)) {
+        if (false === @stream_select($r, $w, $e, 0, 0)) {
             return;
         }
 
@@ -166,4 +167,12 @@ abstract class AbstractPipes implements PipesInterface
             return array($this->pipes[0]);
         }
     }
+
+    /**
+     * @internal
+     */
+    public function handleError($type, $msg)
+    {
+        $this->lastError = $msg;
+    }
 }