ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Symfony\Component\Process\InputStream Class Reference

Provides a way to continuously write to the input of a Process until the InputStream is closed. More...

+ Inheritance diagram for Symfony\Component\Process\InputStream:
+ Collaboration diagram for Symfony\Component\Process\InputStream:

Public Member Functions

 onEmpty (callable $onEmpty=null)
 Sets a callback that is called when the write buffer becomes empty. More...
 
 write ($input)
 Appends an input to the write buffer. More...
 
 close ()
 Closes the write buffer. More...
 
 isClosed ()
 Tells whether the write buffer is closed or not. More...
 
 getIterator ()
 

Private Attributes

 $onEmpty = null
 
 $input = array()
 
 $open = true
 

Detailed Description

Provides a way to continuously write to the input of a Process until the InputStream is closed.

Author
Nicolas Grekas p@tch.nosp@m.work.nosp@m..com

Definition at line 21 of file InputStream.php.

Member Function Documentation

◆ close()

Symfony\Component\Process\InputStream::close ( )

Closes the write buffer.

Definition at line 54 of file InputStream.php.

55  {
56  $this->open = false;
57  }

◆ getIterator()

Symfony\Component\Process\InputStream::getIterator ( )

Definition at line 67 of file InputStream.php.

References Symfony\Component\Process\InputStream\$onEmpty, input, Symfony\Component\Process\InputStream\onEmpty(), and Symfony\Component\Process\InputStream\write().

68  {
69  $this->open = true;
70 
71  while ($this->open || $this->input) {
72  if (!$this->input) {
73  yield '';
74  continue;
75  }
76  $current = array_shift($this->input);
77 
78  if ($current instanceof \Iterator) {
79  foreach ($current as $cur) {
80  yield $cur;
81  }
82  } else {
83  yield $current;
84  }
85  if (!$this->input && $this->open && null !== $onEmpty = $this->onEmpty) {
86  $this->write($onEmpty($this));
87  }
88  }
89  }
write($input)
Appends an input to the write buffer.
Definition: InputStream.php:40
input
Definition: langcheck.php:166
onEmpty(callable $onEmpty=null)
Sets a callback that is called when the write buffer becomes empty.
Definition: InputStream.php:30
+ Here is the call graph for this function:

◆ isClosed()

Symfony\Component\Process\InputStream::isClosed ( )

Tells whether the write buffer is closed or not.

Definition at line 62 of file InputStream.php.

References Symfony\Component\Process\InputStream\$open.

Referenced by Symfony\Component\Process\InputStream\write().

+ Here is the caller graph for this function:

◆ onEmpty()

Symfony\Component\Process\InputStream::onEmpty ( callable  $onEmpty = null)

Sets a callback that is called when the write buffer becomes empty.

Definition at line 30 of file InputStream.php.

References Symfony\Component\Process\InputStream\$onEmpty.

Referenced by Symfony\Component\Process\InputStream\getIterator().

31  {
32  $this->onEmpty = $onEmpty;
33  }
onEmpty(callable $onEmpty=null)
Sets a callback that is called when the write buffer becomes empty.
Definition: InputStream.php:30
+ Here is the caller graph for this function:

◆ write()

Symfony\Component\Process\InputStream::write (   $input)

Appends an input to the write buffer.

Parameters
resource|scalar|

Definition at line 40 of file InputStream.php.

References Symfony\Component\Process\InputStream\$input, input, Symfony\Component\Process\InputStream\isClosed(), and Symfony\Component\Process\ProcessUtils\validateInput().

Referenced by Symfony\Component\Process\InputStream\getIterator().

41  {
42  if (null === $input) {
43  return;
44  }
45  if ($this->isClosed()) {
46  throw new RuntimeException(sprintf('%s is closed', static::class));
47  }
48  $this->input[] = ProcessUtils::validateInput(__METHOD__, $input);
49  }
input
Definition: langcheck.php:166
static validateInput($caller, $input)
Validates and normalizes a Process input.
isClosed()
Tells whether the write buffer is closed or not.
Definition: InputStream.php:62
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $input

Symfony\Component\Process\InputStream::$input = array()
private

Definition at line 24 of file InputStream.php.

Referenced by Symfony\Component\Process\InputStream\write().

◆ $onEmpty

Symfony\Component\Process\InputStream::$onEmpty = null
private

◆ $open

Symfony\Component\Process\InputStream::$open = true
private

Definition at line 25 of file InputStream.php.

Referenced by Symfony\Component\Process\InputStream\isClosed().


The documentation for this class was generated from the following file: