Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

OutputFormatterStyleStack.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 2.43 KiB


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Symfony\Component\Console\Formatter;
013   
014  use Symfony\Component\Console\Exception\InvalidArgumentException;
015   
016  /**
017   * @author Jean-François Simon <contact@jfsimon.fr>
018   */
019  class OutputFormatterStyleStack
020  {
021      /**
022       * @var OutputFormatterStyleInterface[]
023       */
024      private $styles;
025   
026      private $emptyStyle;
027   
028      public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
029      {
030          $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
031          $this->reset();
032      }
033   
034      /**
035       * Resets stack (ie. empty internal arrays).
036       */
037      public function reset()
038      {
039          $this->styles = [];
040      }
041   
042      /**
043       * Pushes a style in the stack.
044       */
045      public function push(OutputFormatterStyleInterface $style)
046      {
047          $this->styles[] = $style;
048      }
049   
050      /**
051       * Pops a style from the stack.
052       *
053       * @return OutputFormatterStyleInterface
054       *
055       * @throws InvalidArgumentException When style tags incorrectly nested
056       */
057      public function pop(OutputFormatterStyleInterface $style = null)
058      {
059          if (empty($this->styles)) {
060              return $this->emptyStyle;
061          }
062   
063          if (null === $style) {
064              return array_pop($this->styles);
065          }
066   
067          foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
068              if ($style->apply('') === $stackedStyle->apply('')) {
069                  $this->styles = \array_slice($this->styles, 0, $index);
070   
071                  return $stackedStyle;
072              }
073          }
074   
075          throw new InvalidArgumentException('Incorrectly nested style tag found.');
076      }
077   
078      /**
079       * Computes current style with stacks top codes.
080       *
081       * @return OutputFormatterStyle
082       */
083      public function getCurrent()
084      {
085          if (empty($this->styles)) {
086              return $this->emptyStyle;
087          }
088   
089          return $this->styles[\count($this->styles) - 1];
090      }
091   
092      /**
093       * @return $this
094       */
095      public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
096      {
097          $this->emptyStyle = $emptyStyle;
098   
099          return $this;
100      }
101   
102      /**
103       * @return OutputFormatterStyleInterface
104       */
105      public function getEmptyStyle()
106      {
107          return $this->emptyStyle;
108      }
109  }
110