Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. OutputFormatterStyleStack.php

function OutputFormatterStyleStack::pop

Pops a style from the stack.

Throws

InvalidArgumentException When style tags incorrectly nested

File

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

Class

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

Namespace

Symfony\Component\Console\Formatter

Code

public function pop(?OutputFormatterStyleInterface $style = null) : OutputFormatterStyleInterface {
    if (!$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.');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal