37 } elseif (is_string(
$input)) {
38 $this->inputBuffer =
$input;
49 foreach ($this->pipes as $pipe) {
52 $this->pipes =
array();
62 $lastError = error_get_last();
65 return isset($lastError[
'message']) &&
false !== stripos($lastError[
'message'],
'interrupted system call');
73 if (!$this->blocked) {
77 foreach ($this->pipes as $pipe) {
78 stream_set_blocking($pipe, 0);
80 if (is_resource($this->
input)) {
81 stream_set_blocking($this->
input, 0);
84 $this->blocked =
false;
94 if (!isset($this->pipes[0])) {
103 stream_set_blocking(
$input, 0);
104 } elseif (!isset($this->inputBuffer[0])) {
107 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)));
111 $this->inputBuffer =
$input;
112 $this->
input->next();
123 if (
false ===
$n = @stream_select(
$r,
$w, $e, 0, 0)) {
127 foreach (
$w as $stdin) {
128 if (isset($this->inputBuffer[0])) {
129 $written = fwrite($stdin, $this->inputBuffer);
130 $this->inputBuffer = substr($this->inputBuffer, $written);
131 if (isset($this->inputBuffer[0])) {
132 return array($this->pipes[0]);
139 if (!isset(
$data[0])) {
142 $written = fwrite($stdin,
$data);
144 if (isset(
$data[0])) {
145 $this->inputBuffer =
$data;
147 return array($this->pipes[0]);
151 if ($this->
input instanceof \Iterator) {
152 $this->
input->next();
161 if (!isset($this->inputBuffer[0]) && !($this->
input instanceof \Iterator ? $this->
input->valid() :
$this->input)) {
163 fclose($this->pipes[0]);
164 unset($this->pipes[0]);
168 return array($this->pipes[0]);
Add rich text string
The name of the decorator.
write()
Writes input to stdin.
hasSystemCallBeenInterrupted()
Returns true if a system call has been interrupted.
Create styles array
The data for the language used.
PipesInterface manages descriptors and pipes for the use of proc_open.
close()
{Closes file handles and pipes.}
unblock()
Unblocks streams.