Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

DebugFormatterHelper.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 4.07 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\Helper;
 013   
 014  /**
 015   * Helps outputting debug information when running an external program from a command.
 016   *
 017   * An external program can be a Process, an HTTP request, or anything else.
 018   *
 019   * @author Fabien Potencier <fabien@symfony.com>
 020   */
 021  class DebugFormatterHelper extends Helper
 022  {
 023      private $colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
 024      private $started = [];
 025      private $count = -1;
 026   
 027      /**
 028       * Starts a debug formatting session.
 029       *
 030       * @param string $id      The id of the formatting session
 031       * @param string $message The message to display
 032       * @param string $prefix  The prefix to use
 033       *
 034       * @return string
 035       */
 036      public function start($id, $message, $prefix = 'RUN')
 037      {
 038          $this->started[$id] = ['border' => ++$this->count % \count($this->colors)];
 039   
 040          return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
 041      }
 042   
 043      /**
 044       * Adds progress to a formatting session.
 045       *
 046       * @param string $id          The id of the formatting session
 047       * @param string $buffer      The message to display
 048       * @param bool   $error       Whether to consider the buffer as error
 049       * @param string $prefix      The prefix for output
 050       * @param string $errorPrefix The prefix for error output
 051       *
 052       * @return string
 053       */
 054      public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
 055      {
 056          $message = '';
 057   
 058          if ($error) {
 059              if (isset($this->started[$id]['out'])) {
 060                  $message .= "\n";
 061                  unset($this->started[$id]['out']);
 062              }
 063              if (!isset($this->started[$id]['err'])) {
 064                  $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
 065                  $this->started[$id]['err'] = true;
 066              }
 067   
 068              $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
 069          } else {
 070              if (isset($this->started[$id]['err'])) {
 071                  $message .= "\n";
 072                  unset($this->started[$id]['err']);
 073              }
 074              if (!isset($this->started[$id]['out'])) {
 075                  $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
 076                  $this->started[$id]['out'] = true;
 077              }
 078   
 079              $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
 080          }
 081   
 082          return $message;
 083      }
 084   
 085      /**
 086       * Stops a formatting session.
 087       *
 088       * @param string $id         The id of the formatting session
 089       * @param string $message    The message to display
 090       * @param bool   $successful Whether to consider the result as success
 091       * @param string $prefix     The prefix for the end output
 092       *
 093       * @return string
 094       */
 095      public function stop($id, $message, $successful, $prefix = 'RES')
 096      {
 097          $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
 098   
 099          if ($successful) {
 100              return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
 101          }
 102   
 103          $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
 104   
 105          unset($this->started[$id]['out'], $this->started[$id]['err']);
 106   
 107          return $message;
 108      }
 109   
 110      /**
 111       * @param string $id The id of the formatting session
 112       *
 113       * @return string
 114       */
 115      private function getBorder($id)
 116      {
 117          return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
 118      }
 119   
 120      /**
 121       * {@inheritdoc}
 122       */
 123      public function getName()
 124      {
 125          return 'debug_formatter';
 126      }
 127  }
 128