output/formatting/styles/Stack.php
public function pop(interfaces\Style $searched = null) : interfaces\Style
    {
        if (empty($this->styles)) {
            return $this->default;
        }

        if (!isset($searched)) {
            return array_pop($this->styles);
        }

        // Given a specific Style to search for, we need to compare the Styles to find the index at which
        // the Style resides, so that we can pop off the part of the Stack starting at the index.
        /* @var interfaces\Style $stackedStyle */
        foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
            // In order to support nested inline styles, we need to compare identity of the output,
            // not just of the instances.
            // @todo Strict equality of the instances may be sufficient depending on how the Formatter gets implemented.
            if ($searched->apply('') === $stackedStyle->apply('')) {
                $this->styles = array_slice($this->styles, 0, $index);

                return $stackedStyle;
            }
        }

        throw new \InvalidArgumentException('Encountered an incorrectly nested formatting style tag');
    }
public function pop(interfaces\Style $searched = null) : interfaces\Style
    {
        if (empty($this->styles)) {
            return $this->default;
        }

        if (!isset($searched)) {
            return array_pop($this->styles);
        }

        // Given a specific Style to search for, we need to compare the Styles to find the index at which
        // the Style resides, so that we can pop off the part of the Stack starting at the index.
        /* @var interfaces\Style $stackedStyle */
        foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
            // In order to support nested inline styles, we need to compare identity of the output,
            // not just of the instances.
            // @todo Strict equality of the instances may be sufficient depending on how the Formatter gets implemented.
            if ($searched->apply('') === $stackedStyle->apply('')) {
                $this->styles = array_slice($this->styles, 0, $index);

                return $stackedStyle;
            }
        }

        throw new \InvalidArgumentException('Encountered an incorrectly nested formatting style tag');
    }
public function pop ( interfaces \ Style $ searched = null ) : interfaces \ Style { if ( empty ( $ this -> styles ) ) { return $ this -> default ; } if ( ! isset ( $ searched ) ) { return array_pop ( $ this -> styles ) ; } // Given a specific Style to search for, we need to compare the Styles to find the index at which // the Style resides, so that we can pop off the part of the Stack starting at the index. /* @var interfaces\Style $stackedStyle */ foreach ( array_reverse ( $ this -> styles , true ) as $ index => $ stackedStyle ) { // In order to support nested inline styles, we need to compare identity of the output, // not just of the instances. // @todo Strict equality of the instances may be sufficient depending on how the Formatter gets implemented. if ( $ searched -> apply ( '' ) === $ stackedStyle -> apply ( '' ) ) { $ this -> styles = array_slice ( $ this -> styles , 0 , $ index ) ; return $ stackedStyle ; } } throw new \ InvalidArgumentException ( 'Encountered an incorrectly nested formatting style tag' ) ; }
Pops a style from the Stack.

@param   interfaces\Style $searched          An optional, specific Style to pop from the Stack. If it is not
the current element in the Stack, the Stack will be sliced and
all Styles present after this instance will also be popped off.
@return  interfaces\Style                    The popped Style.
@throws  \InvalidArgumentException           When a Style was given but couldn't be found in the Stack.
Pops a style from the Stack .