12 namespace Symfony\Component\Finder\Shell;
78 public static function escape($input)
80 return escapeshellcmd($input);
90 public static function quote($input)
92 return escapeshellarg($input);
104 $this->bits[] = $bit;
118 array_unshift($this->bits, $bit);
120 foreach ($this->labels as $label => $index) {
121 $this->labels[$label] += 1;
136 $this->bits[] = self::quote($arg);
150 $this->bits[] = self::escape($esc);
164 public function ins($label)
166 if (isset($this->labels[$label])) {
167 throw new \RuntimeException(sprintf(
'Label "%s" already exists.', $label));
170 $this->bits[] = self::create($this);
171 $this->labels[$label] = count($this->bits) - 1;
173 return $this->bits[$this->labels[$label]];
185 public function get($label)
187 if (!isset($this->labels[$label])) {
188 throw new \RuntimeException(sprintf(
'Label "%s" does not exist.', $label));
191 return $this->bits[$this->labels[$label]];
203 if (null === $this->parent) {
204 throw new \RuntimeException(
'Calling end on root command doesn\'t make sense.');
217 return count($this->bits);
250 exec($this->
join(), $output);
252 $process = proc_open($this->
join(), array(0 => array(
'pipe',
'r'), 1 => array(
'pipe',
'w'), 2 => array(
'pipe',
'w')), $pipes);
253 $output = preg_split(
'~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
255 if ($error = stream_get_contents($pipes[2])) {
259 proc_close($process);
262 return $output ?: array();
272 return implode(
' ', array_filter(
273 array_map(
function ($bit) {
274 return $bit instanceof
Command ? $bit->
join() : ($bit ?: null);
276 function ($bit) {
return null !== $bit; }
290 array_splice($this->bits, $index, 0, $bit instanceof
self ? array($bit) : $bit);