@@ -37,8 +37,11 @@ |
||
37 | 37 | <div id="frame-code-args-<?=$index?>" class="code-block frame-args"> |
38 | 38 | <?= $frameArgs ?> |
39 | 39 | </div> |
40 | - <?php else: ?> |
|
40 | + <?php else { |
|
41 | + : ?> |
|
41 | 42 | <div class="frame-noArgument"><?= e(__('exception.noArguments')) ?></div> |
42 | - <?php endif; ?> |
|
43 | + <?php endif; |
|
44 | +} |
|
45 | +?> |
|
43 | 46 | </div> |
44 | 47 | <?php endforeach; ?> |
45 | 48 | \ No newline at end of file |
@@ -21,10 +21,13 @@ |
||
21 | 21 | <?php endforeach; ?> |
22 | 22 | </tbody> |
23 | 23 | </table> |
24 | - <?php else : ?> |
|
24 | + <?php else { |
|
25 | + : ?> |
|
25 | 26 | <label class="empty"><?= e($label) ?></label> |
26 | 27 | <span class="empty"><?= e(__('exception.empty')) ?></span> |
27 | - <?php endif; ?> |
|
28 | + <?php endif; |
|
29 | +} |
|
30 | +?> |
|
28 | 31 | </div> |
29 | 32 | <?php endforeach; ?> |
30 | 33 | </div> |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | <div class="frame-info-class"> |
13 | 13 | <?php if ($frame->getClass() == '') : ?> |
14 | 14 | <span class="frame-function"><?= e($frame->getFunction()) ?></span> |
15 | - <?php else: ?> |
|
15 | + <?php else { |
|
16 | + : ?> |
|
16 | 17 | <span class="frame-class"><?= e($frame->getClass()) ?></span> |
17 | 18 | <?php if ($frame->getFunction() != '') : ?> |
18 | 19 | <span class="frame-function"><?= e($frame->getFunction()) ?></span> |
@@ -26,5 +27,7 @@ discard block |
||
26 | 27 | </div> |
27 | 28 | |
28 | 29 | </div> |
29 | -<?php endforeach; ?> |
|
30 | +<?php endforeach; |
|
31 | +} |
|
32 | +?> |
|
30 | 33 | </div> |
31 | 34 | \ No newline at end of file |
@@ -4,9 +4,12 @@ |
||
4 | 4 | <?php foreach ($class as $i => $name) : ?> |
5 | 5 | <?php if ($i == count($class) - 1): ?> |
6 | 6 | <h1><?= $template->escape($name) ?></h1> |
7 | - <?php else: ?> |
|
7 | + <?php else { |
|
8 | + : ?> |
|
8 | 9 | <?= $template->escape($name).' \\' ?> |
9 | - <?php endif; ?> |
|
10 | + <?php endif; |
|
11 | +} |
|
12 | +?> |
|
10 | 13 | <?php endforeach; ?> |
11 | 14 | <?php if ($code): ?> |
12 | 15 | <span class="subtitle" title="Exception Code">(<?= $template->escape($code) ?>)</span> |
@@ -32,160 +32,160 @@ |
||
32 | 32 | */ |
33 | 33 | class Supervisor |
34 | 34 | { |
35 | - /** |
|
36 | - * Get exception. |
|
37 | - * |
|
38 | - * @var \Throwable $exception |
|
39 | - */ |
|
40 | - protected $exception; |
|
41 | - |
|
42 | - /** |
|
43 | - * The frame execute errors. |
|
44 | - * |
|
45 | - * @var string $frames |
|
46 | - */ |
|
47 | - protected $frames; |
|
48 | - |
|
49 | - /** |
|
50 | - * Constructor. The Supervisor class instance. |
|
51 | - * |
|
52 | - * @param \Throwable $exception |
|
53 | - * |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function __construct($exception) |
|
57 | - { |
|
58 | - $this->exception = $exception; |
|
59 | - } |
|
35 | + /** |
|
36 | + * Get exception. |
|
37 | + * |
|
38 | + * @var \Throwable $exception |
|
39 | + */ |
|
40 | + protected $exception; |
|
41 | + |
|
42 | + /** |
|
43 | + * The frame execute errors. |
|
44 | + * |
|
45 | + * @var string $frames |
|
46 | + */ |
|
47 | + protected $frames; |
|
48 | + |
|
49 | + /** |
|
50 | + * Constructor. The Supervisor class instance. |
|
51 | + * |
|
52 | + * @param \Throwable $exception |
|
53 | + * |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function __construct($exception) |
|
57 | + { |
|
58 | + $this->exception = $exception; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Returns an iterator for the inspected exception's frames. |
|
63 | - * |
|
64 | - * @param \Throwable $exception |
|
65 | - * |
|
66 | - * @return array |
|
67 | - */ |
|
68 | - public function getFrames() |
|
69 | - { |
|
70 | - if ($this->frames === null) |
|
71 | - { |
|
72 | - $frames = $this->getTrace($this->exception); |
|
73 | - |
|
74 | - // Fill empty line/file info for call_user_func_array usages |
|
75 | - foreach ($frames as $k => $frame) |
|
76 | - { |
|
77 | - if (empty($frame['file'])) |
|
78 | - { |
|
79 | - // Default values when file and line are missing |
|
80 | - $file = '[PHP internal Code]'; |
|
81 | - $line = 0; |
|
82 | - $next_frame = ! empty($frames[$k + 1]) ? $frames[$k + 1] : []; |
|
83 | - $frames[$k]['file'] = $file; |
|
84 | - $frames[$k]['line'] = $line; |
|
85 | - } |
|
86 | - } |
|
61 | + /** |
|
62 | + * Returns an iterator for the inspected exception's frames. |
|
63 | + * |
|
64 | + * @param \Throwable $exception |
|
65 | + * |
|
66 | + * @return array |
|
67 | + */ |
|
68 | + public function getFrames() |
|
69 | + { |
|
70 | + if ($this->frames === null) |
|
71 | + { |
|
72 | + $frames = $this->getTrace($this->exception); |
|
73 | + |
|
74 | + // Fill empty line/file info for call_user_func_array usages |
|
75 | + foreach ($frames as $k => $frame) |
|
76 | + { |
|
77 | + if (empty($frame['file'])) |
|
78 | + { |
|
79 | + // Default values when file and line are missing |
|
80 | + $file = '[PHP internal Code]'; |
|
81 | + $line = 0; |
|
82 | + $next_frame = ! empty($frames[$k + 1]) ? $frames[$k + 1] : []; |
|
83 | + $frames[$k]['file'] = $file; |
|
84 | + $frames[$k]['line'] = $line; |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | - // Find latest non-error handling frame index ($i) used to remove error handling frames |
|
89 | - $i = 0; |
|
90 | - |
|
91 | - foreach ($frames as $k => $frame) |
|
92 | - { |
|
93 | - if ($frame['file'] == $this->exception->getFile() && $frame['line'] == $this->exception->getLine()) |
|
94 | - { |
|
95 | - $i = $k; |
|
96 | - } |
|
97 | - } |
|
98 | - // Remove error handling frames |
|
99 | - if ($i > 0) |
|
100 | - { |
|
101 | - array_splice($frames, 0, $i); |
|
102 | - } |
|
88 | + // Find latest non-error handling frame index ($i) used to remove error handling frames |
|
89 | + $i = 0; |
|
90 | + |
|
91 | + foreach ($frames as $k => $frame) |
|
92 | + { |
|
93 | + if ($frame['file'] == $this->exception->getFile() && $frame['line'] == $this->exception->getLine()) |
|
94 | + { |
|
95 | + $i = $k; |
|
96 | + } |
|
97 | + } |
|
98 | + // Remove error handling frames |
|
99 | + if ($i > 0) |
|
100 | + { |
|
101 | + array_splice($frames, 0, $i); |
|
102 | + } |
|
103 | 103 | |
104 | - $firstFrame = $this->getFrameFromException($this->exception); |
|
105 | - array_unshift($frames, $firstFrame); |
|
106 | - |
|
107 | - $this->frames = new Collection($frames); |
|
108 | - } |
|
109 | - |
|
110 | - return $this->frames; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Given an exception, generates an array in the format generated by Exception::getTrace(). |
|
115 | - * |
|
116 | - * @param \Throwable $exception |
|
117 | - * |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - protected function getFrameFromException(Throwable $exception) |
|
121 | - { |
|
122 | - return [ |
|
123 | - 'file' => $exception->getFile(), |
|
124 | - 'line' => $exception->getLine(), |
|
125 | - 'class' => get_class($exception), |
|
126 | - 'code' => $exception->getCode(), |
|
127 | - 'args' => [ |
|
128 | - $exception->getMessage(), |
|
129 | - ], |
|
130 | - ]; |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Gets exception already specified. |
|
135 | - * |
|
136 | - * @return \Throwable |
|
137 | - */ |
|
138 | - public function getException() |
|
139 | - { |
|
140 | - return $this->exception; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Gets the message of exception. |
|
145 | - * |
|
146 | - * @return string |
|
147 | - */ |
|
148 | - public function getExceptionMessage() |
|
149 | - { |
|
150 | - return $this->exception->getMessage(); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Gets the class name of exception. |
|
155 | - * |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function getExceptionName() |
|
159 | - { |
|
160 | - return getClass($this->exception); |
|
161 | - } |
|
104 | + $firstFrame = $this->getFrameFromException($this->exception); |
|
105 | + array_unshift($frames, $firstFrame); |
|
106 | + |
|
107 | + $this->frames = new Collection($frames); |
|
108 | + } |
|
109 | + |
|
110 | + return $this->frames; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Given an exception, generates an array in the format generated by Exception::getTrace(). |
|
115 | + * |
|
116 | + * @param \Throwable $exception |
|
117 | + * |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + protected function getFrameFromException(Throwable $exception) |
|
121 | + { |
|
122 | + return [ |
|
123 | + 'file' => $exception->getFile(), |
|
124 | + 'line' => $exception->getLine(), |
|
125 | + 'class' => get_class($exception), |
|
126 | + 'code' => $exception->getCode(), |
|
127 | + 'args' => [ |
|
128 | + $exception->getMessage(), |
|
129 | + ], |
|
130 | + ]; |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Gets exception already specified. |
|
135 | + * |
|
136 | + * @return \Throwable |
|
137 | + */ |
|
138 | + public function getException() |
|
139 | + { |
|
140 | + return $this->exception; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Gets the message of exception. |
|
145 | + * |
|
146 | + * @return string |
|
147 | + */ |
|
148 | + public function getExceptionMessage() |
|
149 | + { |
|
150 | + return $this->exception->getMessage(); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Gets the class name of exception. |
|
155 | + * |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function getExceptionName() |
|
159 | + { |
|
160 | + return getClass($this->exception); |
|
161 | + } |
|
162 | 162 | |
163 | - /** |
|
164 | - * Gets the backtrace from an exception. |
|
165 | - * |
|
166 | - * @param \Throwable $exception |
|
167 | - * |
|
168 | - * @return array |
|
169 | - */ |
|
170 | - protected function getTrace($exception) |
|
171 | - { |
|
172 | - $traces = $exception->getTrace(); |
|
173 | - |
|
174 | - if ( ! $exception instanceof ErrorException) |
|
175 | - { |
|
176 | - return $traces; |
|
177 | - } |
|
178 | - |
|
179 | - if ( ! extension_loaded('xdebug') || ! xdebug_is_enabled()) |
|
180 | - { |
|
181 | - return []; |
|
182 | - } |
|
163 | + /** |
|
164 | + * Gets the backtrace from an exception. |
|
165 | + * |
|
166 | + * @param \Throwable $exception |
|
167 | + * |
|
168 | + * @return array |
|
169 | + */ |
|
170 | + protected function getTrace($exception) |
|
171 | + { |
|
172 | + $traces = $exception->getTrace(); |
|
173 | + |
|
174 | + if ( ! $exception instanceof ErrorException) |
|
175 | + { |
|
176 | + return $traces; |
|
177 | + } |
|
178 | + |
|
179 | + if ( ! extension_loaded('xdebug') || ! xdebug_is_enabled()) |
|
180 | + { |
|
181 | + return []; |
|
182 | + } |
|
183 | 183 | |
184 | - // Use xdebug to get the full stack trace and remove the shutdown handler stack trace |
|
185 | - $stack = array_reverse(xdebug_get_function_stack()); |
|
186 | - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
187 | - $traces = array_diff_key($stack, $trace); |
|
184 | + // Use xdebug to get the full stack trace and remove the shutdown handler stack trace |
|
185 | + $stack = array_reverse(xdebug_get_function_stack()); |
|
186 | + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
|
187 | + $traces = array_diff_key($stack, $trace); |
|
188 | 188 | |
189 | - return $traces; |
|
190 | - } |
|
189 | + return $traces; |
|
190 | + } |
|
191 | 191 | } |
192 | 192 | \ No newline at end of file |
@@ -51,7 +51,7 @@ |
||
51 | 51 | */ |
52 | 52 | public function __construct(array $frames) |
53 | 53 | { |
54 | - $this->frames = array_map(function ($frame) { |
|
54 | + $this->frames = array_map(function($frame) { |
|
55 | 55 | return new Frame($frame); |
56 | 56 | }, $frames); |
57 | 57 | } |
@@ -153,7 +153,7 @@ |
||
153 | 153 | |
154 | 154 | if ($filter !== null) |
155 | 155 | { |
156 | - $comments = array_filter($comments, function ($comment) use ($filter) { |
|
156 | + $comments = array_filter($comments, function($comment) use ($filter) { |
|
157 | 157 | return $comment['context'] == $filter; |
158 | 158 | }); |
159 | 159 | } |
@@ -34,308 +34,308 @@ |
||
34 | 34 | */ |
35 | 35 | class TemplateHandler |
36 | 36 | { |
37 | - /** |
|
38 | - * Benchmark instance. |
|
39 | - * |
|
40 | - * @var string $benchmark |
|
41 | - */ |
|
42 | - protected $benchmark; |
|
37 | + /** |
|
38 | + * Benchmark instance. |
|
39 | + * |
|
40 | + * @var string $benchmark |
|
41 | + */ |
|
42 | + protected $benchmark; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Nesting level of the output buffering mechanism. |
|
46 | - * |
|
47 | - * @var string $obLevel |
|
48 | - */ |
|
49 | - public $obLevel; |
|
44 | + /** |
|
45 | + * Nesting level of the output buffering mechanism. |
|
46 | + * |
|
47 | + * @var string $obLevel |
|
48 | + */ |
|
49 | + public $obLevel; |
|
50 | 50 | |
51 | - /** |
|
52 | - * The functions of system what control errors and exceptions. |
|
53 | - * |
|
54 | - * @var string $system |
|
55 | - */ |
|
56 | - protected $system; |
|
51 | + /** |
|
52 | + * The functions of system what control errors and exceptions. |
|
53 | + * |
|
54 | + * @var string $system |
|
55 | + */ |
|
56 | + protected $system; |
|
57 | 57 | |
58 | - /** |
|
59 | - * An array of variables to be passed to all templates. |
|
60 | - * |
|
61 | - * @var array $variables |
|
62 | - */ |
|
63 | - protected $variables = []; |
|
58 | + /** |
|
59 | + * An array of variables to be passed to all templates. |
|
60 | + * |
|
61 | + * @var array $variables |
|
62 | + */ |
|
63 | + protected $variables = []; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Constructor. The TemplateHandler class instance. |
|
67 | - * |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - public function __construct() |
|
71 | - { |
|
72 | - $this->system = new System; |
|
73 | - $this->benchmark = new Benchmark; |
|
74 | - $this->obLevel = $this->system->getOutputBufferLevel(); |
|
75 | - } |
|
65 | + /** |
|
66 | + * Constructor. The TemplateHandler class instance. |
|
67 | + * |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + public function __construct() |
|
71 | + { |
|
72 | + $this->system = new System; |
|
73 | + $this->benchmark = new Benchmark; |
|
74 | + $this->obLevel = $this->system->getOutputBufferLevel(); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Clean Path: This makes nicer looking paths for the error output. |
|
79 | - * |
|
80 | - * @param string $file |
|
81 | - * |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function cleanPath($file) |
|
85 | - { |
|
86 | - if (strpos($file, APP_PATH) === 0) |
|
87 | - { |
|
88 | - $file = 'APP_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(APP_PATH)); |
|
89 | - } |
|
90 | - elseif (strpos($file, SYS_PATH) === 0) |
|
91 | - { |
|
92 | - $file = 'SYS_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SYS_PATH)); |
|
93 | - } |
|
94 | - elseif (strpos($file, CON_PATH) === 0) |
|
95 | - { |
|
96 | - $file = 'CON_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(CON_PATH)); |
|
97 | - } |
|
98 | - elseif (strpos($file, RES_PATH) === 0) |
|
99 | - { |
|
100 | - $file = 'RES_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(RES_PATH)); |
|
101 | - } |
|
77 | + /** |
|
78 | + * Clean Path: This makes nicer looking paths for the error output. |
|
79 | + * |
|
80 | + * @param string $file |
|
81 | + * |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function cleanPath($file) |
|
85 | + { |
|
86 | + if (strpos($file, APP_PATH) === 0) |
|
87 | + { |
|
88 | + $file = 'APP_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(APP_PATH)); |
|
89 | + } |
|
90 | + elseif (strpos($file, SYS_PATH) === 0) |
|
91 | + { |
|
92 | + $file = 'SYS_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SYS_PATH)); |
|
93 | + } |
|
94 | + elseif (strpos($file, CON_PATH) === 0) |
|
95 | + { |
|
96 | + $file = 'CON_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(CON_PATH)); |
|
97 | + } |
|
98 | + elseif (strpos($file, RES_PATH) === 0) |
|
99 | + { |
|
100 | + $file = 'RES_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(RES_PATH)); |
|
101 | + } |
|
102 | 102 | |
103 | - return $file; |
|
104 | - } |
|
103 | + return $file; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Display memory usage in real-world units. Intended for use |
|
108 | - * with memory_get_usage, etc. |
|
109 | - * |
|
110 | - * @param int $bytes |
|
111 | - * |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function displayMemory(int $bytes) |
|
115 | - { |
|
116 | - if ($bytes < 1024) |
|
117 | - { |
|
118 | - return $bytes.'B'; |
|
119 | - } |
|
120 | - else if ($bytes < 1048576) |
|
121 | - { |
|
122 | - return round($bytes/1024, 2).'KB'; |
|
123 | - } |
|
106 | + /** |
|
107 | + * Display memory usage in real-world units. Intended for use |
|
108 | + * with memory_get_usage, etc. |
|
109 | + * |
|
110 | + * @param int $bytes |
|
111 | + * |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function displayMemory(int $bytes) |
|
115 | + { |
|
116 | + if ($bytes < 1024) |
|
117 | + { |
|
118 | + return $bytes.'B'; |
|
119 | + } |
|
120 | + else if ($bytes < 1048576) |
|
121 | + { |
|
122 | + return round($bytes/1024, 2).'KB'; |
|
123 | + } |
|
124 | 124 | |
125 | - return round($bytes/1048576, 2).'MB'; |
|
126 | - } |
|
125 | + return round($bytes/1048576, 2).'MB'; |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Format the given value into a human readable string. |
|
130 | - * |
|
131 | - * @param mixed $value |
|
132 | - * |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - public function dump($value) |
|
136 | - { |
|
137 | - return htmlspecialchars(print_r($value, true)); |
|
138 | - } |
|
128 | + /** |
|
129 | + * Format the given value into a human readable string. |
|
130 | + * |
|
131 | + * @param mixed $value |
|
132 | + * |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + public function dump($value) |
|
136 | + { |
|
137 | + return htmlspecialchars(print_r($value, true)); |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * Format the args of the given Frame as a human readable html string. |
|
142 | - * |
|
143 | - * @param \Syscodes\Debug\FrameHandler\Frame $frame |
|
144 | - * |
|
145 | - * @return string The rendered html |
|
146 | - */ |
|
147 | - public function dumpArgs(Frame $frame) |
|
148 | - { |
|
149 | - $html = ''; |
|
150 | - $numFrames = count($frame->getArgs()); |
|
140 | + /** |
|
141 | + * Format the args of the given Frame as a human readable html string. |
|
142 | + * |
|
143 | + * @param \Syscodes\Debug\FrameHandler\Frame $frame |
|
144 | + * |
|
145 | + * @return string The rendered html |
|
146 | + */ |
|
147 | + public function dumpArgs(Frame $frame) |
|
148 | + { |
|
149 | + $html = ''; |
|
150 | + $numFrames = count($frame->getArgs()); |
|
151 | 151 | |
152 | - if ($numFrames > 0) |
|
153 | - { |
|
154 | - $html = '<ol class="linenums">'; |
|
152 | + if ($numFrames > 0) |
|
153 | + { |
|
154 | + $html = '<ol class="linenums">'; |
|
155 | 155 | |
156 | - foreach ($frame->getArgs() as $j => $frameArg) |
|
157 | - { |
|
158 | - $html .= '<li>'.$this->dump($frameArg).'</li>'; |
|
159 | - } |
|
156 | + foreach ($frame->getArgs() as $j => $frameArg) |
|
157 | + { |
|
158 | + $html .= '<li>'.$this->dump($frameArg).'</li>'; |
|
159 | + } |
|
160 | 160 | |
161 | - $html .= '</ol>'; |
|
162 | - } |
|
161 | + $html .= '</ol>'; |
|
162 | + } |
|
163 | 163 | |
164 | - return $html; |
|
165 | - } |
|
164 | + return $html; |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * Escapes a string for output in an HTML document. |
|
169 | - * |
|
170 | - * @param string $text |
|
171 | - * |
|
172 | - * @return string |
|
173 | - */ |
|
174 | - public function escape($text) |
|
175 | - { |
|
176 | - $flags = ENT_QUOTES; |
|
167 | + /** |
|
168 | + * Escapes a string for output in an HTML document. |
|
169 | + * |
|
170 | + * @param string $text |
|
171 | + * |
|
172 | + * @return string |
|
173 | + */ |
|
174 | + public function escape($text) |
|
175 | + { |
|
176 | + $flags = ENT_QUOTES; |
|
177 | 177 | |
178 | - // HHVM has all constants defined, but only ENT_IGNORE |
|
179 | - // works at the moment |
|
180 | - if (defined("ENT_SUBSTITUTE") && ! defined("HHVM_VERSION")) |
|
181 | - { |
|
182 | - $flags |= ENT_SUBSTITUTE; |
|
183 | - } |
|
184 | - else |
|
185 | - { |
|
186 | - $flags |= ENT_IGNORE; |
|
187 | - } |
|
178 | + // HHVM has all constants defined, but only ENT_IGNORE |
|
179 | + // works at the moment |
|
180 | + if (defined("ENT_SUBSTITUTE") && ! defined("HHVM_VERSION")) |
|
181 | + { |
|
182 | + $flags |= ENT_SUBSTITUTE; |
|
183 | + } |
|
184 | + else |
|
185 | + { |
|
186 | + $flags |= ENT_IGNORE; |
|
187 | + } |
|
188 | 188 | |
189 | - $text = str_replace(chr(9), ' ', $text); |
|
189 | + $text = str_replace(chr(9), ' ', $text); |
|
190 | 190 | |
191 | - return htmlspecialchars($text, $flags, "UTF-8"); |
|
192 | - } |
|
191 | + return htmlspecialchars($text, $flags, "UTF-8"); |
|
192 | + } |
|
193 | 193 | |
194 | - /** |
|
195 | - * Returns all variables for this helper. |
|
196 | - * |
|
197 | - * @return array |
|
198 | - */ |
|
199 | - public function getVariables() |
|
200 | - { |
|
201 | - return $this->variables; |
|
202 | - } |
|
194 | + /** |
|
195 | + * Returns all variables for this helper. |
|
196 | + * |
|
197 | + * @return array |
|
198 | + */ |
|
199 | + public function getVariables() |
|
200 | + { |
|
201 | + return $this->variables; |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * Creates a syntax-highlighted version of a PHP file. |
|
206 | - * |
|
207 | - * @param string $file |
|
208 | - * @param int $lineNumber |
|
209 | - * @param int $lines |
|
210 | - * |
|
211 | - * @return bool|string |
|
212 | - * |
|
213 | - * @throws \Exception |
|
214 | - */ |
|
215 | - public function highlightFile($file, $lineNumber, $lines = 15) |
|
216 | - { |
|
217 | - if (empty ($file) || ! is_readable($file)) |
|
218 | - { |
|
219 | - return false; |
|
220 | - } |
|
204 | + /** |
|
205 | + * Creates a syntax-highlighted version of a PHP file. |
|
206 | + * |
|
207 | + * @param string $file |
|
208 | + * @param int $lineNumber |
|
209 | + * @param int $lines |
|
210 | + * |
|
211 | + * @return bool|string |
|
212 | + * |
|
213 | + * @throws \Exception |
|
214 | + */ |
|
215 | + public function highlightFile($file, $lineNumber, $lines = 15) |
|
216 | + { |
|
217 | + if (empty ($file) || ! is_readable($file)) |
|
218 | + { |
|
219 | + return false; |
|
220 | + } |
|
221 | 221 | |
222 | - // Set our highlight colors: |
|
223 | - if (function_exists('ini_set')) |
|
224 | - { |
|
225 | - ini_set('highlight.comment', '#C5C5C5'); |
|
226 | - ini_set('highlight.default', '#5399BA'); |
|
227 | - ini_set('highlight.html', '#06B'); |
|
228 | - ini_set('highlight.keyword', '#7081A5;'); |
|
229 | - ini_set('highlight.string', '#d8A134'); |
|
230 | - } |
|
222 | + // Set our highlight colors: |
|
223 | + if (function_exists('ini_set')) |
|
224 | + { |
|
225 | + ini_set('highlight.comment', '#C5C5C5'); |
|
226 | + ini_set('highlight.default', '#5399BA'); |
|
227 | + ini_set('highlight.html', '#06B'); |
|
228 | + ini_set('highlight.keyword', '#7081A5;'); |
|
229 | + ini_set('highlight.string', '#d8A134'); |
|
230 | + } |
|
231 | 231 | |
232 | - try |
|
233 | - { |
|
234 | - $origin = file_get_contents($file); |
|
235 | - } |
|
236 | - catch (Exception $e) |
|
237 | - { |
|
238 | - return false; |
|
239 | - } |
|
232 | + try |
|
233 | + { |
|
234 | + $origin = file_get_contents($file); |
|
235 | + } |
|
236 | + catch (Exception $e) |
|
237 | + { |
|
238 | + return false; |
|
239 | + } |
|
240 | 240 | |
241 | - $origin = str_replace(["\r\n", "\r"], "\n", $origin); |
|
242 | - $origin = explode("\n", highlight_string($origin , true)); |
|
243 | - $origin = str_replace('<br />', "\n", $origin [1]); |
|
241 | + $origin = str_replace(["\r\n", "\r"], "\n", $origin); |
|
242 | + $origin = explode("\n", highlight_string($origin , true)); |
|
243 | + $origin = str_replace('<br />', "\n", $origin [1]); |
|
244 | 244 | |
245 | - $origin = explode("\n", str_replace("\r\n", "\n", $origin)); |
|
245 | + $origin = explode("\n", str_replace("\r\n", "\n", $origin)); |
|
246 | 246 | |
247 | - // Get just the part to show |
|
248 | - $start = $lineNumber - (int)round($lines / 2); |
|
249 | - $start = $start < 0 ? 0 : $start; |
|
247 | + // Get just the part to show |
|
248 | + $start = $lineNumber - (int)round($lines / 2); |
|
249 | + $start = $start < 0 ? 0 : $start; |
|
250 | 250 | |
251 | - // Get just the lines we need to display, while keeping line numbers... |
|
252 | - $origin = array_splice($origin, $start, $lines, true); |
|
251 | + // Get just the lines we need to display, while keeping line numbers... |
|
252 | + $origin = array_splice($origin, $start, $lines, true); |
|
253 | 253 | |
254 | - // Used to format the line number in the source |
|
255 | - $format = '% '.strlen($start + $lines).'d'; |
|
254 | + // Used to format the line number in the source |
|
255 | + $format = '% '.strlen($start + $lines).'d'; |
|
256 | 256 | |
257 | - $out = ''; |
|
258 | - // Because the highlighting may have an uneven number |
|
259 | - // of open and close span tags on one line, we need |
|
260 | - // to ensure we can close them all to get the lines |
|
261 | - // showing correctly. |
|
262 | - $spans = 1; |
|
257 | + $out = ''; |
|
258 | + // Because the highlighting may have an uneven number |
|
259 | + // of open and close span tags on one line, we need |
|
260 | + // to ensure we can close them all to get the lines |
|
261 | + // showing correctly. |
|
262 | + $spans = 1; |
|
263 | 263 | |
264 | - foreach ($origin as $n => $row) |
|
265 | - { |
|
266 | - $spans += substr_count($row, '<span') - substr_count($row, '</span'); |
|
267 | - $row = str_replace(["\r", "\n"], ['', ''], $row); |
|
264 | + foreach ($origin as $n => $row) |
|
265 | + { |
|
266 | + $spans += substr_count($row, '<span') - substr_count($row, '</span'); |
|
267 | + $row = str_replace(["\r", "\n"], ['', ''], $row); |
|
268 | 268 | |
269 | - if (($n+$start+1) == $lineNumber) |
|
270 | - { |
|
271 | - preg_match_all('#<[^>]+>#', $row, $tags); |
|
272 | - $out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s", |
|
273 | - $n + $start + 1, |
|
274 | - strip_tags($row), |
|
275 | - implode('', $tags[0]) |
|
276 | - ); |
|
277 | - } |
|
278 | - else |
|
279 | - { |
|
280 | - $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start +1, $row) ."\n"; |
|
281 | - } |
|
282 | - } |
|
269 | + if (($n+$start+1) == $lineNumber) |
|
270 | + { |
|
271 | + preg_match_all('#<[^>]+>#', $row, $tags); |
|
272 | + $out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s", |
|
273 | + $n + $start + 1, |
|
274 | + strip_tags($row), |
|
275 | + implode('', $tags[0]) |
|
276 | + ); |
|
277 | + } |
|
278 | + else |
|
279 | + { |
|
280 | + $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start +1, $row) ."\n"; |
|
281 | + } |
|
282 | + } |
|
283 | 283 | |
284 | - $out .= str_repeat('</span>', $spans); |
|
284 | + $out .= str_repeat('</span>', $spans); |
|
285 | 285 | |
286 | - return '<pre class="code-blocks"><code>'.$out.'</code></pre>'; |
|
287 | - } |
|
286 | + return '<pre class="code-blocks"><code>'.$out.'</code></pre>'; |
|
287 | + } |
|
288 | 288 | |
289 | - /** |
|
290 | - * Sets the variables to be passed to all templates rendered |
|
291 | - * by this template helper. |
|
292 | - * |
|
293 | - * @param array $variables |
|
294 | - * |
|
295 | - * @return void |
|
296 | - */ |
|
297 | - public function setVariables(array $variables) |
|
298 | - { |
|
299 | - $this->variables = $variables; |
|
300 | - } |
|
289 | + /** |
|
290 | + * Sets the variables to be passed to all templates rendered |
|
291 | + * by this template helper. |
|
292 | + * |
|
293 | + * @param array $variables |
|
294 | + * |
|
295 | + * @return void |
|
296 | + */ |
|
297 | + public function setVariables(array $variables) |
|
298 | + { |
|
299 | + $this->variables = $variables; |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * Convert a string to a slug version of itself. |
|
304 | - * |
|
305 | - * @param string $original |
|
306 | - * |
|
307 | - * @return string |
|
308 | - */ |
|
309 | - public function slug($original) |
|
310 | - { |
|
311 | - $slug = str_replace(" ", "-", $original); |
|
312 | - $slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug); |
|
302 | + /** |
|
303 | + * Convert a string to a slug version of itself. |
|
304 | + * |
|
305 | + * @param string $original |
|
306 | + * |
|
307 | + * @return string |
|
308 | + */ |
|
309 | + public function slug($original) |
|
310 | + { |
|
311 | + $slug = str_replace(" ", "-", $original); |
|
312 | + $slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug); |
|
313 | 313 | |
314 | - return strtolower($slug); |
|
315 | - } |
|
314 | + return strtolower($slug); |
|
315 | + } |
|
316 | 316 | |
317 | - /** |
|
318 | - * Given an exception and status code will display the error to the client. |
|
319 | - * |
|
320 | - * @param string $template |
|
321 | - * |
|
322 | - * @return void |
|
323 | - */ |
|
324 | - public function render($template) |
|
325 | - { |
|
326 | - $vars = $this->getVariables(); |
|
317 | + /** |
|
318 | + * Given an exception and status code will display the error to the client. |
|
319 | + * |
|
320 | + * @param string $template |
|
321 | + * |
|
322 | + * @return void |
|
323 | + */ |
|
324 | + public function render($template) |
|
325 | + { |
|
326 | + $vars = $this->getVariables(); |
|
327 | 327 | |
328 | - $vars['template'] = $this; |
|
328 | + $vars['template'] = $this; |
|
329 | 329 | |
330 | - if ($this->system->getOutputBufferLevel() > $this->obLevel + 1) |
|
331 | - { |
|
332 | - @$this->system->endOutputBuffering(); |
|
333 | - } |
|
330 | + if ($this->system->getOutputBufferLevel() > $this->obLevel + 1) |
|
331 | + { |
|
332 | + @$this->system->endOutputBuffering(); |
|
333 | + } |
|
334 | 334 | |
335 | - // Instantiate the error view and prepare the vars |
|
336 | - call_user_func(function () { |
|
337 | - extract(func_get_arg(1)); |
|
338 | - include func_get_arg(0); |
|
339 | - }, $template, $vars); |
|
340 | - } |
|
335 | + // Instantiate the error view and prepare the vars |
|
336 | + call_user_func(function () { |
|
337 | + extract(func_get_arg(1)); |
|
338 | + include func_get_arg(0); |
|
339 | + }, $template, $vars); |
|
340 | + } |
|
341 | 341 | } |
342 | 342 | \ No newline at end of file |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | } |
120 | 120 | else if ($bytes < 1048576) |
121 | 121 | { |
122 | - return round($bytes/1024, 2).'KB'; |
|
122 | + return round($bytes / 1024, 2).'KB'; |
|
123 | 123 | } |
124 | 124 | |
125 | - return round($bytes/1048576, 2).'MB'; |
|
125 | + return round($bytes / 1048576, 2).'MB'; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -239,17 +239,17 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | $origin = str_replace(["\r\n", "\r"], "\n", $origin); |
242 | - $origin = explode("\n", highlight_string($origin , true)); |
|
242 | + $origin = explode("\n", highlight_string($origin, true)); |
|
243 | 243 | $origin = str_replace('<br />', "\n", $origin [1]); |
244 | 244 | |
245 | 245 | $origin = explode("\n", str_replace("\r\n", "\n", $origin)); |
246 | 246 | |
247 | 247 | // Get just the part to show |
248 | - $start = $lineNumber - (int)round($lines / 2); |
|
248 | + $start = $lineNumber - (int) round($lines / 2); |
|
249 | 249 | $start = $start < 0 ? 0 : $start; |
250 | 250 | |
251 | 251 | // Get just the lines we need to display, while keeping line numbers... |
252 | - $origin = array_splice($origin, $start, $lines, true); |
|
252 | + $origin = array_splice($origin, $start, $lines, true); |
|
253 | 253 | |
254 | 254 | // Used to format the line number in the source |
255 | 255 | $format = '% '.strlen($start + $lines).'d'; |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $spans += substr_count($row, '<span') - substr_count($row, '</span'); |
267 | 267 | $row = str_replace(["\r", "\n"], ['', ''], $row); |
268 | 268 | |
269 | - if (($n+$start+1) == $lineNumber) |
|
269 | + if (($n + $start + 1) == $lineNumber) |
|
270 | 270 | { |
271 | 271 | preg_match_all('#<[^>]+>#', $row, $tags); |
272 | 272 | $out .= sprintf("<span class='line highlight'><span class='number'>{$format}</span> %s\n</span>%s", |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | } |
278 | 278 | else |
279 | 279 | { |
280 | - $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start +1, $row) ."\n"; |
|
280 | + $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start + 1, $row)."\n"; |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | public function slug($original) |
310 | 310 | { |
311 | 311 | $slug = str_replace(" ", "-", $original); |
312 | - $slug = preg_replace('/[^\w\d\-\_]/i',' ', $slug); |
|
312 | + $slug = preg_replace('/[^\w\d\-\_]/i', ' ', $slug); |
|
313 | 313 | |
314 | 314 | return strtolower($slug); |
315 | 315 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | } |
334 | 334 | |
335 | 335 | // Instantiate the error view and prepare the vars |
336 | - call_user_func(function () { |
|
336 | + call_user_func(function() { |
|
337 | 337 | extract(func_get_arg(1)); |
338 | 338 | include func_get_arg(0); |
339 | 339 | }, $template, $vars); |
@@ -86,16 +86,13 @@ discard block |
||
86 | 86 | if (strpos($file, APP_PATH) === 0) |
87 | 87 | { |
88 | 88 | $file = 'APP_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(APP_PATH)); |
89 | - } |
|
90 | - elseif (strpos($file, SYS_PATH) === 0) |
|
89 | + } elseif (strpos($file, SYS_PATH) === 0) |
|
91 | 90 | { |
92 | 91 | $file = 'SYS_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(SYS_PATH)); |
93 | - } |
|
94 | - elseif (strpos($file, CON_PATH) === 0) |
|
92 | + } elseif (strpos($file, CON_PATH) === 0) |
|
95 | 93 | { |
96 | 94 | $file = 'CON_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(CON_PATH)); |
97 | - } |
|
98 | - elseif (strpos($file, RES_PATH) === 0) |
|
95 | + } elseif (strpos($file, RES_PATH) === 0) |
|
99 | 96 | { |
100 | 97 | $file = 'RES_PATH'.DIRECTORY_SEPARATOR.substr($file, strlen(RES_PATH)); |
101 | 98 | } |
@@ -116,8 +113,7 @@ discard block |
||
116 | 113 | if ($bytes < 1024) |
117 | 114 | { |
118 | 115 | return $bytes.'B'; |
119 | - } |
|
120 | - else if ($bytes < 1048576) |
|
116 | + } else if ($bytes < 1048576) |
|
121 | 117 | { |
122 | 118 | return round($bytes/1024, 2).'KB'; |
123 | 119 | } |
@@ -180,8 +176,7 @@ discard block |
||
180 | 176 | if (defined("ENT_SUBSTITUTE") && ! defined("HHVM_VERSION")) |
181 | 177 | { |
182 | 178 | $flags |= ENT_SUBSTITUTE; |
183 | - } |
|
184 | - else |
|
179 | + } else |
|
185 | 180 | { |
186 | 181 | $flags |= ENT_IGNORE; |
187 | 182 | } |
@@ -232,8 +227,7 @@ discard block |
||
232 | 227 | try |
233 | 228 | { |
234 | 229 | $origin = file_get_contents($file); |
235 | - } |
|
236 | - catch (Exception $e) |
|
230 | + } catch (Exception $e) |
|
237 | 231 | { |
238 | 232 | return false; |
239 | 233 | } |
@@ -274,8 +268,7 @@ discard block |
||
274 | 268 | strip_tags($row), |
275 | 269 | implode('', $tags[0]) |
276 | 270 | ); |
277 | - } |
|
278 | - else |
|
271 | + } else |
|
279 | 272 | { |
280 | 273 | $out .= sprintf('<span class="number">'.$format.'</span> %s <span class="line">', $n + $start +1, $row) ."\n"; |
281 | 274 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | $caughtLength = $this->caughtLength = 0; |
163 | 163 | |
164 | - ob_start(function ($buffer) { |
|
164 | + ob_start(function($buffer) { |
|
165 | 165 | |
166 | 166 | $this->caughtBuffer = $buffer; |
167 | 167 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | if (isset($this->caughtBuffer[0])) |
175 | 175 | { |
176 | - ob_start(function ($buffer) { |
|
176 | + ob_start(function($buffer) { |
|
177 | 177 | |
178 | 178 | if ($this->caughtLength) |
179 | 179 | { |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | |
489 | 489 | if (is_string($frmt)) |
490 | 490 | { |
491 | - $index = strpos($f = $frmt, '&', max(strrpos($f, '%f'), strrpos($f, '%l')) ?: strlen($f)); |
|
491 | + $index = strpos($f = $frmt, '&', max(strrpos($f, '%f'), strrpos($f, '%l')) ?: strlen($f)); |
|
492 | 492 | $frmt = [substr($f, 0, $index)] + preg_split('/&([^>]++)>/', substr($f, $index), -1, PREG_SPLIT_DELIM_CAPTURE); |
493 | 493 | |
494 | 494 | for ($index = 1; isset($frmt[$index]); ++$index) |
@@ -200,8 +200,7 @@ discard block |
||
200 | 200 | { |
201 | 201 | ($this->handler)($exception); |
202 | 202 | $caughtLength = $this->caughtLength; |
203 | - } |
|
204 | - catch (Exception $e) |
|
203 | + } catch (Exception $e) |
|
205 | 204 | { |
206 | 205 | if ( ! $caughtLength) |
207 | 206 | { |
@@ -358,8 +357,7 @@ discard block |
||
358 | 357 | |
359 | 358 | $content .= "</table>\n</div>\n"; |
360 | 359 | } |
361 | - } |
|
362 | - catch (Exception $e) |
|
360 | + } catch (Exception $e) |
|
363 | 361 | { |
364 | 362 | if ($this->debug) |
365 | 363 | { |
@@ -368,8 +366,7 @@ discard block |
||
368 | 366 | $e->getClass(), |
369 | 367 | $this->escapeHtml($e->getMessage()) |
370 | 368 | ); |
371 | - } |
|
372 | - else |
|
369 | + } else |
|
373 | 370 | { |
374 | 371 | $title = 'Whoops, looks like something went wrong'; |
375 | 372 | } |
@@ -501,14 +498,12 @@ discard block |
||
501 | 498 | } |
502 | 499 | |
503 | 500 | $data = strstr($frmt[0], ['%f' => $file, '%l' => $line]); |
504 | - } |
|
505 | - else |
|
501 | + } else |
|
506 | 502 | { |
507 | 503 | try |
508 | 504 | { |
509 | 505 | $data = $frmt->format($file, $line); |
510 | - } |
|
511 | - catch (Exception $e) |
|
506 | + } catch (Exception $e) |
|
512 | 507 | { |
513 | 508 | return sprintf('<span class="block trace-file-path">in <span title="%s%3$s"><strong>%s</strong>%s</span></span>', |
514 | 509 | $this->escapeHtml($path), $file, 0 < $line ? ' line '.$line : ''); |
@@ -535,24 +530,19 @@ discard block |
||
535 | 530 | if ($value[0] === 'object') |
536 | 531 | { |
537 | 532 | $formatValue = sprintf('<em>(Object)</em>%s', $this->formatClass($value[1])); |
538 | - } |
|
539 | - elseif ($value[0] === 'array') |
|
533 | + } elseif ($value[0] === 'array') |
|
540 | 534 | { |
541 | 535 | $formatValue = sprintf('<em>(array)</em>%s', is_array($value[1]) ? $this->formatArgs($value[1]) : $value[1]); |
542 | - } |
|
543 | - elseif ($value[0] === 'null') |
|
536 | + } elseif ($value[0] === 'null') |
|
544 | 537 | { |
545 | 538 | $formatValue = '<em>Null</em>'; |
546 | - } |
|
547 | - elseif ($value[0] === 'boolean') |
|
539 | + } elseif ($value[0] === 'boolean') |
|
548 | 540 | { |
549 | 541 | $formatValue = '<em>'.strtolower(var_export($value[1], true)).'</em>'; |
550 | - } |
|
551 | - elseif ($value[0] === 'resource') |
|
542 | + } elseif ($value[0] === 'resource') |
|
552 | 543 | { |
553 | 544 | $formatValue = '<em>resource</em>'; |
554 | - } |
|
555 | - else |
|
545 | + } else |
|
556 | 546 | { |
557 | 547 | $formatValue = str_replace("\n", '', $this->escapeHtml(var_export($value[1], true))); |
558 | 548 | } |