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 |
FlattenException.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\HttpKernel\Exception;
013
014 use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
015
016 /**
017 * FlattenException wraps a PHP Exception to be able to serialize it.
018 *
019 * Basically, this class removes all objects from the trace.
020 *
021 * @author Fabien Potencier <fabien@symfony.com>
022 *
023 * @deprecated Deprecated in 2.3, to be removed in 3.0. Use the same class from the Debug component instead.
024 */
025 class FlattenException
026 {
027 private $handler;
028
029 public static function __callStatic($method, $args)
030 {
031 if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
032 throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_called_class(), $method));
033 }
034
035 return call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
036 }
037
038 public function __call($method, $args)
039 {
040 if (!isset($this->handler)) {
041 $this->handler = new DebugFlattenException();
042 }
043
044 if (!method_exists($this->handler, $method)) {
045 throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $method));
046 }
047
048 return call_user_func_array(array($this->handler, $method), $args);
049 }
050 }
051
052 namespace Symfony\Component\Debug\Exception;
053
054 use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
055 use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
056
057 /**
058 * FlattenException wraps a PHP Exception to be able to serialize it.
059 *
060 * Basically, this class removes all objects from the trace.
061 *
062 * @author Fabien Potencier <fabien@symfony.com>
063 */
064 class FlattenException extends LegacyFlattenException
065 {
066 private $message;
067 private $code;
068 private $previous;
069 private $trace;
070 private $class;
071 private $statusCode;
072 private $headers;
073 private $file;
074 private $line;
075
076 public static function create(\Exception $exception, $statusCode = null, array $headers = array())
077 {
078 $e = new static();
079 $e->setMessage($exception->getMessage());
080 $e->setCode($exception->getCode());
081
082 if ($exception instanceof HttpExceptionInterface) {
083 $statusCode = $exception->getStatusCode();
084 $headers = array_merge($headers, $exception->getHeaders());
085 }
086
087 if (null === $statusCode) {
088 $statusCode = 500;
089 }
090
091 $e->setStatusCode($statusCode);
092 $e->setHeaders($headers);
093 $e->setTraceFromException($exception);
094 $e->setClass(get_class($exception));
095 $e->setFile($exception->getFile());
096 $e->setLine($exception->getLine());
097
098 $previous = $exception->getPrevious();
099
100 if ($previous instanceof \Exception) {
101 $e->setPrevious(static::create($previous));
102 } elseif ($previous instanceof \Throwable) {
103 $e->setPrevious(static::create(new FatalThrowableError($previous)));
104 }
105
106 return $e;
107 }
108
109 public function toArray()
110 {
111 $exceptions = array();
112 foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
113 $exceptions[] = array(
114 'message' => $exception->getMessage(),
115 'class' => $exception->getClass(),
116 'trace' => $exception->getTrace(),
117 );
118 }
119
120 return $exceptions;
121 }
122
123 public function getStatusCode()
124 {
125 return $this->statusCode;
126 }
127
128 public function setStatusCode($code)
129 {
130 $this->statusCode = $code;
131 }
132
133 public function getHeaders()
134 {
135 return $this->headers;
136 }
137
138 public function setHeaders(array $headers)
139 {
140 $this->headers = $headers;
141 }
142
143 public function getClass()
144 {
145 return $this->class;
146 }
147
148 public function setClass($class)
149 {
150 $this->class = $class;
151 }
152
153 public function getFile()
154 {
155 return $this->file;
156 }
157
158 public function setFile($file)
159 {
160 $this->file = $file;
161 }
162
163 public function getLine()
164 {
165 return $this->line;
166 }
167
168 public function setLine($line)
169 {
170 $this->line = $line;
171 }
172
173 public function getMessage()
174 {
175 return $this->message;
176 }
177
178 public function setMessage($message)
179 {
180 $this->message = $message;
181 }
182
183 public function getCode()
184 {
185 return $this->code;
186 }
187
188 public function setCode($code)
189 {
190 $this->code = $code;
191 }
192
193 public function getPrevious()
194 {
195 return $this->previous;
196 }
197
198 public function setPrevious(FlattenException $previous)
199 {
200 $this->previous = $previous;
201 }
202
203 public function getAllPrevious()
204 {
205 $exceptions = array();
206 $e = $this;
207 while ($e = $e->getPrevious()) {
208 $exceptions[] = $e;
209 }
210
211 return $exceptions;
212 }
213
214 public function getTrace()
215 {
216 return $this->trace;
217 }
218
219 public function setTraceFromException(\Exception $exception)
220 {
221 $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
222 }
223
224 public function setTrace($trace, $file, $line)
225 {
226 $this->trace = array();
227 $this->trace[] = array(
228 'namespace' => '',
229 'short_class' => '',
230 'class' => '',
231 'type' => '',
232 'function' => '',
233 'file' => $file,
234 'line' => $line,
235 'args' => array(),
236 );
237 foreach ($trace as $entry) {
238 $class = '';
239 $namespace = '';
240 if (isset($entry['class'])) {
241 $parts = explode('\\', $entry['class']);
242 $class = array_pop($parts);
243 $namespace = implode('\\', $parts);
244 }
245
246 $this->trace[] = array(
247 'namespace' => $namespace,
248 'short_class' => $class,
249 'class' => isset($entry['class']) ? $entry['class'] : '',
250 'type' => isset($entry['type']) ? $entry['type'] : '',
251 'function' => isset($entry['function']) ? $entry['function'] : null,
252 'file' => isset($entry['file']) ? $entry['file'] : null,
253 'line' => isset($entry['line']) ? $entry['line'] : null,
254 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
255 );
256 }
257 }
258
259 private function flattenArgs($args, $level = 0, &$count = 0)
260 {
261 $result = array();
262 foreach ($args as $key => $value) {
263 if (++$count > 1e4) {
264 return array('array', '*SKIPPED over 10000 entries*');
265 }
266 if ($value instanceof \__PHP_Incomplete_Class) {
267 // is_object() returns false on PHP<=7.1
268 $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
269 } elseif (is_object($value)) {
270 $result[$key] = array('object', get_class($value));
271 } elseif (is_array($value)) {
272 if ($level > 10) {
273 $result[$key] = array('array', '*DEEP NESTED ARRAY*');
274 } else {
275 $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
276 }
277 } elseif (null === $value) {
278 $result[$key] = array('null', null);
279 } elseif (is_bool($value)) {
280 $result[$key] = array('boolean', $value);
281 } elseif (is_resource($value)) {
282 $result[$key] = array('resource', get_resource_type($value));
283 } else {
284 $result[$key] = array('string', (string) $value);
285 }
286 }
287
288 return $result;
289 }
290
291 private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
292 {
293 $array = new \ArrayObject($value);
294
295 return $array['__PHP_Incomplete_Class_Name'];
296 }
297 }
298