You are here

public function OutputFormatterStyleStack::pop in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Formatter/OutputFormatterStyleStack.php \Symfony\Component\Console\Formatter\OutputFormatterStyleStack::pop()

Pops a style from the stack.

Parameters

OutputFormatterStyleInterface|null $style:

Return value

OutputFormatterStyleInterface

Throws

\InvalidArgumentException When style tags incorrectly nested

File

vendor/symfony/console/Formatter/OutputFormatterStyleStack.php, line 67

Class

OutputFormatterStyleStack
@author Jean-François Simon <contact@jfsimon.fr>

Namespace

Symfony\Component\Console\Formatter

Code

public function pop(OutputFormatterStyleInterface $style = null) {
  if (empty($this->styles)) {
    return $this->emptyStyle;
  }
  if (null === $style) {
    return array_pop($this->styles);
  }
  foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
    if ($style
      ->apply('') === $stackedStyle
      ->apply('')) {
      $this->styles = array_slice($this->styles, 0, $index);
      return $stackedStyle;
    }
  }
  throw new \InvalidArgumentException('Incorrectly nested style tag found.');
}