@@ -42,450 +42,450 @@ |
||
42 | 42 | */ |
43 | 43 | class PleasingPageHandler extends MainHandler |
44 | 44 | { |
45 | - /** |
|
46 | - * The brand main of handler. |
|
47 | - * |
|
48 | - * @var string $brand |
|
49 | - */ |
|
50 | - protected $brand = 'Lenevor Debug'; |
|
51 | - |
|
52 | - /** |
|
53 | - * A string identifier for a known IDE/text editor, or a closure |
|
54 | - * that resolves a string that can be used to open a given file |
|
55 | - * in an editor. |
|
56 | - * |
|
57 | - * @var mixed $editor |
|
58 | - */ |
|
59 | - protected $editor; |
|
60 | - |
|
61 | - /** |
|
62 | - * A list of known editor strings. |
|
63 | - * |
|
64 | - * @var array $editors |
|
65 | - */ |
|
66 | - protected $editors = [ |
|
67 | - "vscode" => "vscode://file/%file:%line", |
|
68 | - "sublime" => "subl://open?url=file://%file&line=%line", |
|
69 | - "phpstorm" => "phpstorm://open?file://%file&line=%line", |
|
70 | - "textmate" => "txmt://open?url=file://%file&line=%line", |
|
71 | - "atom" => "atom://core/open/file?filename=%file&line=%line", |
|
72 | - ]; |
|
45 | + /** |
|
46 | + * The brand main of handler. |
|
47 | + * |
|
48 | + * @var string $brand |
|
49 | + */ |
|
50 | + protected $brand = 'Lenevor Debug'; |
|
51 | + |
|
52 | + /** |
|
53 | + * A string identifier for a known IDE/text editor, or a closure |
|
54 | + * that resolves a string that can be used to open a given file |
|
55 | + * in an editor. |
|
56 | + * |
|
57 | + * @var mixed $editor |
|
58 | + */ |
|
59 | + protected $editor; |
|
60 | + |
|
61 | + /** |
|
62 | + * A list of known editor strings. |
|
63 | + * |
|
64 | + * @var array $editors |
|
65 | + */ |
|
66 | + protected $editors = [ |
|
67 | + "vscode" => "vscode://file/%file:%line", |
|
68 | + "sublime" => "subl://open?url=file://%file&line=%line", |
|
69 | + "phpstorm" => "phpstorm://open?file://%file&line=%line", |
|
70 | + "textmate" => "txmt://open?url=file://%file&line=%line", |
|
71 | + "atom" => "atom://core/open/file?filename=%file&line=%line", |
|
72 | + ]; |
|
73 | 73 | |
74 | - /** |
|
75 | - * The page title main of handler. |
|
76 | - * |
|
77 | - * @var string $pageTitle |
|
78 | - */ |
|
79 | - protected $pageTitle = 'Lenevor Debug! There was an error.'; |
|
74 | + /** |
|
75 | + * The page title main of handler. |
|
76 | + * |
|
77 | + * @var string $pageTitle |
|
78 | + */ |
|
79 | + protected $pageTitle = 'Lenevor Debug! There was an error.'; |
|
80 | 80 | |
81 | - /** |
|
82 | - * Fast lookup cache for known resource locations. |
|
83 | - * |
|
84 | - * @var array $resourceCache |
|
85 | - */ |
|
86 | - protected $resourceCache = []; |
|
81 | + /** |
|
82 | + * Fast lookup cache for known resource locations. |
|
83 | + * |
|
84 | + * @var array $resourceCache |
|
85 | + */ |
|
86 | + protected $resourceCache = []; |
|
87 | 87 | |
88 | - /** |
|
89 | - * The path to the directory containing the html error template directories. |
|
90 | - * |
|
91 | - * @var array $searchPaths |
|
92 | - */ |
|
93 | - protected $searchPaths = []; |
|
94 | - |
|
95 | - /** |
|
96 | - * Gets the table of data. |
|
97 | - * |
|
98 | - * @var array $tables |
|
99 | - */ |
|
100 | - protected $tables = []; |
|
88 | + /** |
|
89 | + * The path to the directory containing the html error template directories. |
|
90 | + * |
|
91 | + * @var array $searchPaths |
|
92 | + */ |
|
93 | + protected $searchPaths = []; |
|
94 | + |
|
95 | + /** |
|
96 | + * Gets the table of data. |
|
97 | + * |
|
98 | + * @var array $tables |
|
99 | + */ |
|
100 | + protected $tables = []; |
|
101 | 101 | |
102 | - /** |
|
103 | - * The template handler system. |
|
104 | - * |
|
105 | - * @var string $template |
|
106 | - */ |
|
107 | - protected $template; |
|
102 | + /** |
|
103 | + * The template handler system. |
|
104 | + * |
|
105 | + * @var string $template |
|
106 | + */ |
|
107 | + protected $template; |
|
108 | 108 | |
109 | - /** |
|
110 | - * Constructor. The PleasingPageHandler class. |
|
111 | - * |
|
112 | - * @return void |
|
113 | - */ |
|
114 | - public function __construct() |
|
115 | - { |
|
116 | - $this->template = new TemplateHandler; |
|
117 | - $this->searchPaths[] = dirname(__DIR__).DIRECTORY_SEPARATOR.'Resources'; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Adds an editor resolver, identified by a string name, and that may be a |
|
122 | - * string path, or a callable resolver. |
|
123 | - * |
|
124 | - * @param string $identifier |
|
125 | - * @param string|\Callable $resolver |
|
126 | - * |
|
127 | - * @return void |
|
128 | - */ |
|
129 | - public function addEditor($identifier, $resolver) |
|
130 | - { |
|
131 | - $this->editors[$identifier] = $resolver; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Adds an entry to the list of tables displayed in the template. |
|
136 | - * The expected data is a simple associative array. Any nested arrays |
|
137 | - * will be flattened with print_r. |
|
138 | - * |
|
139 | - * @param \Syscodes\Contracts\Debug\Table $table |
|
140 | - * |
|
141 | - * @return array |
|
142 | - */ |
|
143 | - public function addTables(Table $table) |
|
144 | - { |
|
145 | - $this->tables[] = $table; |
|
146 | - } |
|
109 | + /** |
|
110 | + * Constructor. The PleasingPageHandler class. |
|
111 | + * |
|
112 | + * @return void |
|
113 | + */ |
|
114 | + public function __construct() |
|
115 | + { |
|
116 | + $this->template = new TemplateHandler; |
|
117 | + $this->searchPaths[] = dirname(__DIR__).DIRECTORY_SEPARATOR.'Resources'; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Adds an editor resolver, identified by a string name, and that may be a |
|
122 | + * string path, or a callable resolver. |
|
123 | + * |
|
124 | + * @param string $identifier |
|
125 | + * @param string|\Callable $resolver |
|
126 | + * |
|
127 | + * @return void |
|
128 | + */ |
|
129 | + public function addEditor($identifier, $resolver) |
|
130 | + { |
|
131 | + $this->editors[$identifier] = $resolver; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Adds an entry to the list of tables displayed in the template. |
|
136 | + * The expected data is a simple associative array. Any nested arrays |
|
137 | + * will be flattened with print_r. |
|
138 | + * |
|
139 | + * @param \Syscodes\Contracts\Debug\Table $table |
|
140 | + * |
|
141 | + * @return array |
|
142 | + */ |
|
143 | + public function addTables(Table $table) |
|
144 | + { |
|
145 | + $this->tables[] = $table; |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Gathers the variables that will be made available to the view. |
|
150 | - * |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - protected function collectionVars() |
|
154 | - { |
|
155 | - $supervisor = $this->getSupervisor(); |
|
156 | - $style = file_get_contents($this->getResource('css/debug.base.css')); |
|
157 | - $jscript = file_get_contents($this->getResource('js/debug.base.js')); |
|
158 | - $tables = array_merge($this->getDefaultTables(), $this->tables); |
|
148 | + /** |
|
149 | + * Gathers the variables that will be made available to the view. |
|
150 | + * |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + protected function collectionVars() |
|
154 | + { |
|
155 | + $supervisor = $this->getSupervisor(); |
|
156 | + $style = file_get_contents($this->getResource('css/debug.base.css')); |
|
157 | + $jscript = file_get_contents($this->getResource('js/debug.base.js')); |
|
158 | + $tables = array_merge($this->getDefaultTables(), $this->tables); |
|
159 | 159 | |
160 | - return [ |
|
161 | - 'class' => explode('\\', $supervisor->getExceptionName()), |
|
162 | - 'stylesheet' => preg_replace('#[\r\n\t ]+#', ' ', $style), |
|
163 | - 'javascript' => preg_replace('#[\r\n\t ]+#', ' ', $jscript), |
|
164 | - 'header' => $this->getResource('views/header.php'), |
|
165 | - 'sidebar' => $this->getResource('views/sidebar.php'), |
|
166 | - 'frame_description' => $this->getResource('views/frame_description.php'), |
|
167 | - 'frame_list' => $this->getResource('views/frame_list.php'), |
|
168 | - 'details_panel' => $this->getResource('views/details_panel.php'), |
|
169 | - 'code_source' => $this->getResource('views/code_source.php'), |
|
170 | - 'details_content' => $this->getResource('views/details_content.php'), |
|
171 | - 'footer' => $this->getResource('views/footer.php'), |
|
172 | - 'plain_exception' => Formatter::formatExceptionAsPlainText($this->getSupervisor()), |
|
173 | - 'handler' => $this, |
|
174 | - 'handlers' => $this->getDebug()->getHandlers(), |
|
175 | - 'debug' => $this->getDebug(), |
|
176 | - 'code' => $this->getExceptionCode(), |
|
177 | - 'message' => $supervisor->getExceptionMessage(), |
|
178 | - 'frames' => $this->getExceptionFrames(), |
|
179 | - 'tables' => $this->getProcessTables($tables), |
|
180 | - ]; |
|
181 | - } |
|
160 | + return [ |
|
161 | + 'class' => explode('\\', $supervisor->getExceptionName()), |
|
162 | + 'stylesheet' => preg_replace('#[\r\n\t ]+#', ' ', $style), |
|
163 | + 'javascript' => preg_replace('#[\r\n\t ]+#', ' ', $jscript), |
|
164 | + 'header' => $this->getResource('views/header.php'), |
|
165 | + 'sidebar' => $this->getResource('views/sidebar.php'), |
|
166 | + 'frame_description' => $this->getResource('views/frame_description.php'), |
|
167 | + 'frame_list' => $this->getResource('views/frame_list.php'), |
|
168 | + 'details_panel' => $this->getResource('views/details_panel.php'), |
|
169 | + 'code_source' => $this->getResource('views/code_source.php'), |
|
170 | + 'details_content' => $this->getResource('views/details_content.php'), |
|
171 | + 'footer' => $this->getResource('views/footer.php'), |
|
172 | + 'plain_exception' => Formatter::formatExceptionAsPlainText($this->getSupervisor()), |
|
173 | + 'handler' => $this, |
|
174 | + 'handlers' => $this->getDebug()->getHandlers(), |
|
175 | + 'debug' => $this->getDebug(), |
|
176 | + 'code' => $this->getExceptionCode(), |
|
177 | + 'message' => $supervisor->getExceptionMessage(), |
|
178 | + 'frames' => $this->getExceptionFrames(), |
|
179 | + 'tables' => $this->getProcessTables($tables), |
|
180 | + ]; |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * The way in which the data sender (usually the server) can tell the recipient |
|
185 | - * (the browser, in general) what type of data is being sent in this case, html format tagged. |
|
186 | - * |
|
187 | - * @return string |
|
188 | - */ |
|
189 | - public function contentType() |
|
190 | - { |
|
191 | - return 'text/html;charset=UTF-8'; |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Gets the brand of project. |
|
196 | - * |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - public function getBrand() |
|
200 | - { |
|
201 | - return $this->brand; |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Returns the default tables. |
|
206 | - * |
|
207 | - * @return \Syscodes\Contracts\Debug\Table[] |
|
208 | - */ |
|
209 | - protected function getDefaultTables() |
|
210 | - { |
|
211 | - return [ |
|
212 | - new ArrayTable('GET Data', $_GET), |
|
213 | - new ArrayTable('POST Data', $_POST), |
|
214 | - new ArrayTable('Files', $_FILES), |
|
215 | - new ArrayTable('Cookie', $_COOKIE), |
|
216 | - new ArrayTable('Session', isset($_SESSION) ? $_SESSION : []), |
|
217 | - new ArrayTable('Server/Request Data', $_SERVER), |
|
218 | - new ArrayTable(__('exception.environmentVars'), $_ENV), |
|
219 | - ]; |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Get the code of the exception that is currently being handled. |
|
224 | - * |
|
225 | - * @return string |
|
226 | - */ |
|
227 | - protected function getExceptionCode() |
|
228 | - { |
|
229 | - $exception = $this->getException(); |
|
230 | - $code = $exception->getCode(); |
|
231 | - |
|
232 | - if ($exception instanceof ErrorException) |
|
233 | - { |
|
234 | - $code = Misc::translateErrorCode($exception->getSeverity()); |
|
235 | - } |
|
236 | - |
|
237 | - return (string) $code; |
|
238 | - } |
|
239 | - |
|
240 | - /** |
|
241 | - * Get the stack trace frames of the exception that is currently being handled. |
|
242 | - * |
|
243 | - * @return \Syscodes\Debug\Engine\Supervisor; |
|
244 | - */ |
|
245 | - protected function getExceptionFrames() |
|
246 | - { |
|
247 | - $frames = $this->getSupervisor()->getFrames(); |
|
183 | + /** |
|
184 | + * The way in which the data sender (usually the server) can tell the recipient |
|
185 | + * (the browser, in general) what type of data is being sent in this case, html format tagged. |
|
186 | + * |
|
187 | + * @return string |
|
188 | + */ |
|
189 | + public function contentType() |
|
190 | + { |
|
191 | + return 'text/html;charset=UTF-8'; |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Gets the brand of project. |
|
196 | + * |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + public function getBrand() |
|
200 | + { |
|
201 | + return $this->brand; |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Returns the default tables. |
|
206 | + * |
|
207 | + * @return \Syscodes\Contracts\Debug\Table[] |
|
208 | + */ |
|
209 | + protected function getDefaultTables() |
|
210 | + { |
|
211 | + return [ |
|
212 | + new ArrayTable('GET Data', $_GET), |
|
213 | + new ArrayTable('POST Data', $_POST), |
|
214 | + new ArrayTable('Files', $_FILES), |
|
215 | + new ArrayTable('Cookie', $_COOKIE), |
|
216 | + new ArrayTable('Session', isset($_SESSION) ? $_SESSION : []), |
|
217 | + new ArrayTable('Server/Request Data', $_SERVER), |
|
218 | + new ArrayTable(__('exception.environmentVars'), $_ENV), |
|
219 | + ]; |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Get the code of the exception that is currently being handled. |
|
224 | + * |
|
225 | + * @return string |
|
226 | + */ |
|
227 | + protected function getExceptionCode() |
|
228 | + { |
|
229 | + $exception = $this->getException(); |
|
230 | + $code = $exception->getCode(); |
|
231 | + |
|
232 | + if ($exception instanceof ErrorException) |
|
233 | + { |
|
234 | + $code = Misc::translateErrorCode($exception->getSeverity()); |
|
235 | + } |
|
236 | + |
|
237 | + return (string) $code; |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * Get the stack trace frames of the exception that is currently being handled. |
|
242 | + * |
|
243 | + * @return \Syscodes\Debug\Engine\Supervisor; |
|
244 | + */ |
|
245 | + protected function getExceptionFrames() |
|
246 | + { |
|
247 | + $frames = $this->getSupervisor()->getFrames(); |
|
248 | 248 | |
249 | - return $frames; |
|
250 | - } |
|
249 | + return $frames; |
|
250 | + } |
|
251 | 251 | |
252 | - /** |
|
253 | - * Gets the page title web. |
|
254 | - * |
|
255 | - * @return string |
|
256 | - */ |
|
257 | - public function getPageTitle() |
|
258 | - { |
|
259 | - return $this->pageTitle; |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Processes an array of tables making sure everything is allright. |
|
264 | - * |
|
265 | - * @param \Syscodes\Contracts\Debug\Table[] $tables |
|
266 | - * |
|
267 | - * @return array |
|
268 | - */ |
|
269 | - protected function getProcessTables(array $tables) |
|
270 | - { |
|
271 | - $processTables = []; |
|
272 | - |
|
273 | - foreach ($tables as $table) |
|
274 | - { |
|
275 | - if ( ! $table instanceof Table) |
|
276 | - { |
|
277 | - continue; |
|
278 | - } |
|
279 | - |
|
280 | - $label = $table->getLabel(); |
|
281 | - |
|
282 | - try |
|
283 | - { |
|
284 | - $data = $table->getData(); |
|
285 | - |
|
286 | - if ( ! (is_array($data) || $data instanceof Traversable)) |
|
287 | - { |
|
288 | - $data = []; |
|
289 | - } |
|
290 | - } |
|
291 | - catch (Exception $e) |
|
292 | - { |
|
293 | - $data = []; |
|
294 | - } |
|
295 | - |
|
296 | - $processTables[$label] = $data; |
|
297 | - } |
|
298 | - |
|
299 | - return $processTables; |
|
300 | - } |
|
301 | - |
|
302 | - /** |
|
303 | - * Finds a resource, by its relative path, in all available search paths. |
|
304 | - * |
|
305 | - * @param string $resource |
|
306 | - * |
|
307 | - * @return string |
|
308 | - * |
|
309 | - * @throws \RuntimeException |
|
310 | - */ |
|
311 | - protected function getResource($resource) |
|
312 | - { |
|
313 | - if (isset($this->resourceCache[$resource])) |
|
314 | - { |
|
315 | - return $this->resourceCache[$resource]; |
|
316 | - } |
|
317 | - |
|
318 | - foreach ($this->searchPaths as $path) |
|
319 | - { |
|
320 | - $fullPath = $path.DIRECTORY_SEPARATOR.$resource; |
|
321 | - |
|
322 | - if (is_file($fullPath)) |
|
323 | - { |
|
324 | - // Cache: |
|
325 | - $this->resourceCache[$resource] = $fullPath; |
|
326 | - |
|
327 | - return $fullPath; |
|
328 | - } |
|
329 | - } |
|
330 | - |
|
331 | - throw new RuntimeException( |
|
332 | - "Could not find resource '{$resource}' in any resource paths.". |
|
333 | - "(searched: ".join(", ", $this->searchPaths).")"); |
|
334 | - } |
|
252 | + /** |
|
253 | + * Gets the page title web. |
|
254 | + * |
|
255 | + * @return string |
|
256 | + */ |
|
257 | + public function getPageTitle() |
|
258 | + { |
|
259 | + return $this->pageTitle; |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Processes an array of tables making sure everything is allright. |
|
264 | + * |
|
265 | + * @param \Syscodes\Contracts\Debug\Table[] $tables |
|
266 | + * |
|
267 | + * @return array |
|
268 | + */ |
|
269 | + protected function getProcessTables(array $tables) |
|
270 | + { |
|
271 | + $processTables = []; |
|
272 | + |
|
273 | + foreach ($tables as $table) |
|
274 | + { |
|
275 | + if ( ! $table instanceof Table) |
|
276 | + { |
|
277 | + continue; |
|
278 | + } |
|
279 | + |
|
280 | + $label = $table->getLabel(); |
|
281 | + |
|
282 | + try |
|
283 | + { |
|
284 | + $data = $table->getData(); |
|
285 | + |
|
286 | + if ( ! (is_array($data) || $data instanceof Traversable)) |
|
287 | + { |
|
288 | + $data = []; |
|
289 | + } |
|
290 | + } |
|
291 | + catch (Exception $e) |
|
292 | + { |
|
293 | + $data = []; |
|
294 | + } |
|
295 | + |
|
296 | + $processTables[$label] = $data; |
|
297 | + } |
|
298 | + |
|
299 | + return $processTables; |
|
300 | + } |
|
301 | + |
|
302 | + /** |
|
303 | + * Finds a resource, by its relative path, in all available search paths. |
|
304 | + * |
|
305 | + * @param string $resource |
|
306 | + * |
|
307 | + * @return string |
|
308 | + * |
|
309 | + * @throws \RuntimeException |
|
310 | + */ |
|
311 | + protected function getResource($resource) |
|
312 | + { |
|
313 | + if (isset($this->resourceCache[$resource])) |
|
314 | + { |
|
315 | + return $this->resourceCache[$resource]; |
|
316 | + } |
|
317 | + |
|
318 | + foreach ($this->searchPaths as $path) |
|
319 | + { |
|
320 | + $fullPath = $path.DIRECTORY_SEPARATOR.$resource; |
|
321 | + |
|
322 | + if (is_file($fullPath)) |
|
323 | + { |
|
324 | + // Cache: |
|
325 | + $this->resourceCache[$resource] = $fullPath; |
|
326 | + |
|
327 | + return $fullPath; |
|
328 | + } |
|
329 | + } |
|
330 | + |
|
331 | + throw new RuntimeException( |
|
332 | + "Could not find resource '{$resource}' in any resource paths.". |
|
333 | + "(searched: ".join(", ", $this->searchPaths).")"); |
|
334 | + } |
|
335 | 335 | |
336 | - /** |
|
337 | - * Given an exception and status code will display the error to the client. |
|
338 | - * |
|
339 | - * @return int|null |
|
340 | - */ |
|
341 | - public function handle() |
|
342 | - { |
|
343 | - $templatePath = $this->getResource('debug.layout.php'); |
|
344 | - |
|
345 | - $vars = $this->collectionVars(); |
|
336 | + /** |
|
337 | + * Given an exception and status code will display the error to the client. |
|
338 | + * |
|
339 | + * @return int|null |
|
340 | + */ |
|
341 | + public function handle() |
|
342 | + { |
|
343 | + $templatePath = $this->getResource('debug.layout.php'); |
|
344 | + |
|
345 | + $vars = $this->collectionVars(); |
|
346 | 346 | |
347 | - if (empty($vars['message'])) $vars['message'] = __('exception.noMessage'); |
|
347 | + if (empty($vars['message'])) $vars['message'] = __('exception.noMessage'); |
|
348 | 348 | |
349 | - $this->template->setVariables($vars); |
|
350 | - $this->template->render($templatePath); |
|
349 | + $this->template->setVariables($vars); |
|
350 | + $this->template->render($templatePath); |
|
351 | 351 | |
352 | - return MainHandler::QUIT; |
|
353 | - } |
|
354 | - |
|
355 | - /** |
|
356 | - * Set the editor to use to open referenced files, by a string identifier or callable |
|
357 | - * that will be executed for every file reference. Should return a string. |
|
358 | - * |
|
359 | - * @example $debug->setEditor(function($file, $line) { return "file:///{$file}"; }); |
|
360 | - * @example $debug->setEditor('vscode'); |
|
361 | - * |
|
362 | - * @param string $editor |
|
363 | - * |
|
364 | - * @return void |
|
365 | - * |
|
366 | - * @throws \InvalidArgumentException |
|
367 | - */ |
|
368 | - public function setEditor($editor) |
|
369 | - { |
|
370 | - if ( ! is_callable($editor) && ! isset($this->editors[$editor])) |
|
371 | - { |
|
372 | - throw new InvalidArgumentException("Unknown editor identifier: [{$editor}]. Known editors: " . |
|
373 | - implode(', ', array_keys($this->editors)) |
|
374 | - ); |
|
375 | - } |
|
376 | - |
|
377 | - $this->editor = $editor; |
|
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Given a string file path, and an integer file line, |
|
382 | - * executes the editor resolver and returns. |
|
383 | - * |
|
384 | - * @param string $file |
|
385 | - * @param int $line |
|
386 | - * |
|
387 | - * @return string|bool |
|
388 | - * |
|
389 | - * @throws \UnexpectedValueException |
|
390 | - */ |
|
391 | - public function getEditorAtHref($file, $line) |
|
392 | - { |
|
393 | - $editor = $this->getEditor($file, $line); |
|
394 | - |
|
395 | - if (empty($editor)) |
|
396 | - { |
|
397 | - return false; |
|
398 | - } |
|
399 | - |
|
400 | - if ( ! isset($editor['url']) || ! is_string($editor['url'])) |
|
401 | - { |
|
402 | - throw new UnexpectedValueException(__METHOD__.'should always resolve to a string or a valid editor array'); |
|
403 | - } |
|
404 | - |
|
405 | - $editor['url'] = str_replace("%file", rawurldecode($file), $editor['url']); |
|
406 | - $editor['url'] = str_replace("%line", rawurldecode($line), $editor['url']); |
|
407 | - |
|
408 | - return $editor['url']; |
|
409 | - } |
|
410 | - |
|
411 | - /** |
|
412 | - * The editor must be a valid callable function/closure. |
|
413 | - * |
|
414 | - * @param string $file |
|
415 | - * @param int $line |
|
416 | - * |
|
417 | - * @return array |
|
418 | - */ |
|
419 | - protected function getEditor($file, $line) |
|
420 | - { |
|
421 | - if ( ! $this->editor || ( ! is_string($this->editor) && ! is_callable($this->editor))) |
|
422 | - { |
|
423 | - return []; |
|
424 | - } |
|
425 | - |
|
426 | - if (is_string($this->editor) && isset($this->editors[$this->editor]) && ! is_callable($this->editors[$this->editor])) |
|
427 | - { |
|
428 | - return ['url' => $this->editors[$this->editor]]; |
|
429 | - } |
|
430 | - |
|
431 | - if (is_callable($this->editor) || (isset($this->editors[$this->editor]) && is_callable($this->editors[$this->editor]))) |
|
432 | - { |
|
433 | - if (is_callable($this->editor)) |
|
434 | - { |
|
435 | - $callback = call_user_func($this->editor, $filePath, $line); |
|
436 | - } |
|
437 | - else |
|
438 | - { |
|
439 | - $callback = call_user_func($this->editors[$this->editor], $filePath, $line); |
|
440 | - } |
|
441 | - |
|
442 | - if (empty($callback)) |
|
443 | - { |
|
444 | - return []; |
|
445 | - } |
|
446 | - |
|
447 | - if (is_string($callback)) |
|
448 | - { |
|
449 | - return ['url' => $callback]; |
|
450 | - } |
|
352 | + return MainHandler::QUIT; |
|
353 | + } |
|
354 | + |
|
355 | + /** |
|
356 | + * Set the editor to use to open referenced files, by a string identifier or callable |
|
357 | + * that will be executed for every file reference. Should return a string. |
|
358 | + * |
|
359 | + * @example $debug->setEditor(function($file, $line) { return "file:///{$file}"; }); |
|
360 | + * @example $debug->setEditor('vscode'); |
|
361 | + * |
|
362 | + * @param string $editor |
|
363 | + * |
|
364 | + * @return void |
|
365 | + * |
|
366 | + * @throws \InvalidArgumentException |
|
367 | + */ |
|
368 | + public function setEditor($editor) |
|
369 | + { |
|
370 | + if ( ! is_callable($editor) && ! isset($this->editors[$editor])) |
|
371 | + { |
|
372 | + throw new InvalidArgumentException("Unknown editor identifier: [{$editor}]. Known editors: " . |
|
373 | + implode(', ', array_keys($this->editors)) |
|
374 | + ); |
|
375 | + } |
|
376 | + |
|
377 | + $this->editor = $editor; |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Given a string file path, and an integer file line, |
|
382 | + * executes the editor resolver and returns. |
|
383 | + * |
|
384 | + * @param string $file |
|
385 | + * @param int $line |
|
386 | + * |
|
387 | + * @return string|bool |
|
388 | + * |
|
389 | + * @throws \UnexpectedValueException |
|
390 | + */ |
|
391 | + public function getEditorAtHref($file, $line) |
|
392 | + { |
|
393 | + $editor = $this->getEditor($file, $line); |
|
394 | + |
|
395 | + if (empty($editor)) |
|
396 | + { |
|
397 | + return false; |
|
398 | + } |
|
399 | + |
|
400 | + if ( ! isset($editor['url']) || ! is_string($editor['url'])) |
|
401 | + { |
|
402 | + throw new UnexpectedValueException(__METHOD__.'should always resolve to a string or a valid editor array'); |
|
403 | + } |
|
404 | + |
|
405 | + $editor['url'] = str_replace("%file", rawurldecode($file), $editor['url']); |
|
406 | + $editor['url'] = str_replace("%line", rawurldecode($line), $editor['url']); |
|
407 | + |
|
408 | + return $editor['url']; |
|
409 | + } |
|
410 | + |
|
411 | + /** |
|
412 | + * The editor must be a valid callable function/closure. |
|
413 | + * |
|
414 | + * @param string $file |
|
415 | + * @param int $line |
|
416 | + * |
|
417 | + * @return array |
|
418 | + */ |
|
419 | + protected function getEditor($file, $line) |
|
420 | + { |
|
421 | + if ( ! $this->editor || ( ! is_string($this->editor) && ! is_callable($this->editor))) |
|
422 | + { |
|
423 | + return []; |
|
424 | + } |
|
425 | + |
|
426 | + if (is_string($this->editor) && isset($this->editors[$this->editor]) && ! is_callable($this->editors[$this->editor])) |
|
427 | + { |
|
428 | + return ['url' => $this->editors[$this->editor]]; |
|
429 | + } |
|
430 | + |
|
431 | + if (is_callable($this->editor) || (isset($this->editors[$this->editor]) && is_callable($this->editors[$this->editor]))) |
|
432 | + { |
|
433 | + if (is_callable($this->editor)) |
|
434 | + { |
|
435 | + $callback = call_user_func($this->editor, $filePath, $line); |
|
436 | + } |
|
437 | + else |
|
438 | + { |
|
439 | + $callback = call_user_func($this->editors[$this->editor], $filePath, $line); |
|
440 | + } |
|
441 | + |
|
442 | + if (empty($callback)) |
|
443 | + { |
|
444 | + return []; |
|
445 | + } |
|
446 | + |
|
447 | + if (is_string($callback)) |
|
448 | + { |
|
449 | + return ['url' => $callback]; |
|
450 | + } |
|
451 | 451 | |
452 | - return ['url' => isset($callback['url']) ? $callback['url'] : $callback]; |
|
453 | - } |
|
452 | + return ['url' => isset($callback['url']) ? $callback['url'] : $callback]; |
|
453 | + } |
|
454 | 454 | |
455 | - return []; |
|
456 | - } |
|
457 | - |
|
458 | - /** |
|
459 | - * Registered the editor. |
|
460 | - * |
|
461 | - * @return string |
|
462 | - */ |
|
463 | - public function getEditorcode() |
|
464 | - { |
|
465 | - return $this->editor; |
|
466 | - } |
|
455 | + return []; |
|
456 | + } |
|
457 | + |
|
458 | + /** |
|
459 | + * Registered the editor. |
|
460 | + * |
|
461 | + * @return string |
|
462 | + */ |
|
463 | + public function getEditorcode() |
|
464 | + { |
|
465 | + return $this->editor; |
|
466 | + } |
|
467 | 467 | |
468 | - /** |
|
469 | - * Sets the brand of project. |
|
470 | - * |
|
471 | - * @param string $brand |
|
472 | - * |
|
473 | - * @return void |
|
474 | - */ |
|
475 | - public function setBrand($brand) |
|
476 | - { |
|
477 | - $this->brand = (string) $brand; |
|
478 | - } |
|
468 | + /** |
|
469 | + * Sets the brand of project. |
|
470 | + * |
|
471 | + * @param string $brand |
|
472 | + * |
|
473 | + * @return void |
|
474 | + */ |
|
475 | + public function setBrand($brand) |
|
476 | + { |
|
477 | + $this->brand = (string) $brand; |
|
478 | + } |
|
479 | 479 | |
480 | - /** |
|
481 | - * Sets the page title web. |
|
482 | - * |
|
483 | - * @param string $title |
|
484 | - * |
|
485 | - * @return void |
|
486 | - */ |
|
487 | - public function setPageTitle($title) |
|
488 | - { |
|
489 | - $this->pageTitle = (string) $title; |
|
490 | - } |
|
480 | + /** |
|
481 | + * Sets the page title web. |
|
482 | + * |
|
483 | + * @param string $title |
|
484 | + * |
|
485 | + * @return void |
|
486 | + */ |
|
487 | + public function setPageTitle($title) |
|
488 | + { |
|
489 | + $this->pageTitle = (string) $title; |
|
490 | + } |
|
491 | 491 | } |
492 | 492 | \ No newline at end of file |
@@ -369,7 +369,7 @@ |
||
369 | 369 | { |
370 | 370 | if ( ! is_callable($editor) && ! isset($this->editors[$editor])) |
371 | 371 | { |
372 | - throw new InvalidArgumentException("Unknown editor identifier: [{$editor}]. Known editors: " . |
|
372 | + throw new InvalidArgumentException("Unknown editor identifier: [{$editor}]. Known editors: ". |
|
373 | 373 | implode(', ', array_keys($this->editors)) |
374 | 374 | ); |
375 | 375 | } |
@@ -287,8 +287,7 @@ discard block |
||
287 | 287 | { |
288 | 288 | $data = []; |
289 | 289 | } |
290 | - } |
|
291 | - catch (Exception $e) |
|
290 | + } catch (Exception $e) |
|
292 | 291 | { |
293 | 292 | $data = []; |
294 | 293 | } |
@@ -344,7 +343,9 @@ discard block |
||
344 | 343 | |
345 | 344 | $vars = $this->collectionVars(); |
346 | 345 | |
347 | - if (empty($vars['message'])) $vars['message'] = __('exception.noMessage'); |
|
346 | + if (empty($vars['message'])) { |
|
347 | + $vars['message'] = __('exception.noMessage'); |
|
348 | + } |
|
348 | 349 | |
349 | 350 | $this->template->setVariables($vars); |
350 | 351 | $this->template->render($templatePath); |
@@ -433,8 +434,7 @@ discard block |
||
433 | 434 | if (is_callable($this->editor)) |
434 | 435 | { |
435 | 436 | $callback = call_user_func($this->editor, $filePath, $line); |
436 | - } |
|
437 | - else |
|
437 | + } else |
|
438 | 438 | { |
439 | 439 | $callback = call_user_func($this->editors[$this->editor], $filePath, $line); |
440 | 440 | } |
@@ -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 | } |