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

ParseException.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.34 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\Yaml\Exception;
013   
014  /**
015   * Exception class thrown when an error occurs during parsing.
016   *
017   * @author Fabien Potencier <fabien@symfony.com>
018   */
019  class ParseException extends RuntimeException
020  {
021      private $parsedFile;
022      private $parsedLine;
023      private $snippet;
024      private $rawMessage;
025   
026      /**
027       * @param string          $message    The error message
028       * @param int             $parsedLine The line where the error occurred
029       * @param string|null     $snippet    The snippet of code near the problem
030       * @param string|null     $parsedFile The file name where the error occurred
031       * @param \Exception|null $previous   The previous exception
032       */
033      public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null)
034      {
035          $this->parsedFile = $parsedFile;
036          $this->parsedLine = $parsedLine;
037          $this->snippet = $snippet;
038          $this->rawMessage = $message;
039   
040          $this->updateRepr();
041   
042          parent::__construct($this->message, 0, $previous);
043      }
044   
045      /**
046       * Gets the snippet of code near the error.
047       *
048       * @return string The snippet of code
049       */
050      public function getSnippet()
051      {
052          return $this->snippet;
053      }
054   
055      /**
056       * Sets the snippet of code near the error.
057       *
058       * @param string $snippet The code snippet
059       */
060      public function setSnippet($snippet)
061      {
062          $this->snippet = $snippet;
063   
064          $this->updateRepr();
065      }
066   
067      /**
068       * Gets the filename where the error occurred.
069       *
070       * This method returns null if a string is parsed.
071       *
072       * @return string The filename
073       */
074      public function getParsedFile()
075      {
076          return $this->parsedFile;
077      }
078   
079      /**
080       * Sets the filename where the error occurred.
081       *
082       * @param string $parsedFile The filename
083       */
084      public function setParsedFile($parsedFile)
085      {
086          $this->parsedFile = $parsedFile;
087   
088          $this->updateRepr();
089      }
090   
091      /**
092       * Gets the line where the error occurred.
093       *
094       * @return int The file line
095       */
096      public function getParsedLine()
097      {
098          return $this->parsedLine;
099      }
100   
101      /**
102       * Sets the line where the error occurred.
103       *
104       * @param int $parsedLine The file line
105       */
106      public function setParsedLine($parsedLine)
107      {
108          $this->parsedLine = $parsedLine;
109   
110          $this->updateRepr();
111      }
112   
113      private function updateRepr()
114      {
115          $this->message = $this->rawMessage;
116   
117          $dot = false;
118          if ('.' === substr($this->message, -1)) {
119              $this->message = substr($this->message, 0, -1);
120              $dot = true;
121          }
122   
123          if (null !== $this->parsedFile) {
124              $this->message .= sprintf(' in %s', json_encode($this->parsedFile, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
125          }
126   
127          if ($this->parsedLine >= 0) {
128              $this->message .= sprintf(' at line %d', $this->parsedLine);
129          }
130   
131          if ($this->snippet) {
132              $this->message .= sprintf(' (near "%s")', $this->snippet);
133          }
134   
135          if ($dot) {
136              $this->message .= '.';
137          }
138      }
139  }
140