Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ParseException.php
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 * Constructor.
028 *
029 * @param string $message The error message
030 * @param int $parsedLine The line where the error occurred
031 * @param int $snippet The snippet of code near the problem
032 * @param string $parsedFile The file name where the error occurred
033 * @param \Exception $previous The previous exception
034 */
035 public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null)
036 {
037 $this->parsedFile = $parsedFile;
038 $this->parsedLine = $parsedLine;
039 $this->snippet = $snippet;
040 $this->rawMessage = $message;
041
042 $this->updateRepr();
043
044 parent::__construct($this->message, 0, $previous);
045 }
046
047 /**
048 * Gets the snippet of code near the error.
049 *
050 * @return string The snippet of code
051 */
052 public function getSnippet()
053 {
054 return $this->snippet;
055 }
056
057 /**
058 * Sets the snippet of code near the error.
059 *
060 * @param string $snippet The code snippet
061 */
062 public function setSnippet($snippet)
063 {
064 $this->snippet = $snippet;
065
066 $this->updateRepr();
067 }
068
069 /**
070 * Gets the filename where the error occurred.
071 *
072 * This method returns null if a string is parsed.
073 *
074 * @return string The filename
075 */
076 public function getParsedFile()
077 {
078 return $this->parsedFile;
079 }
080
081 /**
082 * Sets the filename where the error occurred.
083 *
084 * @param string $parsedFile The filename
085 */
086 public function setParsedFile($parsedFile)
087 {
088 $this->parsedFile = $parsedFile;
089
090 $this->updateRepr();
091 }
092
093 /**
094 * Gets the line where the error occurred.
095 *
096 * @return int The file line
097 */
098 public function getParsedLine()
099 {
100 return $this->parsedLine;
101 }
102
103 /**
104 * Sets the line where the error occurred.
105 *
106 * @param int $parsedLine The file line
107 */
108 public function setParsedLine($parsedLine)
109 {
110 $this->parsedLine = $parsedLine;
111
112 $this->updateRepr();
113 }
114
115 private function updateRepr()
116 {
117 $this->message = $this->rawMessage;
118
119 $dot = false;
120 if ('.' === substr($this->message, -1)) {
121 $this->message = substr($this->message, 0, -1);
122 $dot = true;
123 }
124
125 if (null !== $this->parsedFile) {
126 if (PHP_VERSION_ID >= 50400) {
127 $jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
128 } else {
129 $jsonOptions = 0;
130 }
131 $this->message .= sprintf(' in %s', json_encode($this->parsedFile, $jsonOptions));
132 }
133
134 if ($this->parsedLine >= 0) {
135 $this->message .= sprintf(' at line %d', $this->parsedLine);
136 }
137
138 if ($this->snippet) {
139 $this->message .= sprintf(' (near "%s")', $this->snippet);
140 }
141
142 if ($dot) {
143 $this->message .= '.';
144 }
145 }
146 }
147