Completed
Pull Request — master (#286)
by Frank
09:39 queued 06:18
created
plugins/phile/errorHandler/Classes/Development.php 1 patch
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -18,281 +18,281 @@
 block discarded – undo
18 18
  */
19 19
 class Development implements ErrorHandlerInterface {
20 20
 
21
-	/** @var array settings */
22
-	protected $settings;
23
-
24
-	/**
25
-	 * constructor
26
-	 *
27
-	 * @param array $settings
28
-	 */
29
-	public function __construct(array $settings = []) {
30
-		$this->settings = $settings;
31
-	}
32
-
33
-	/**
34
-	 * handle the error
35
-	 *
36
-	 * @param int    $errno
37
-	 * @param string $errstr
38
-	 * @param string $errfile
39
-	 * @param int    $errline
40
-	 * @param array  $errcontext
41
-	 *
42
-	 * @return boolean
43
-	 */
44
-	public function handleError($errno, $errstr, $errfile, $errline, array $errcontext) {
45
-		$backtrace = debug_backtrace();
46
-		$backtrace = array_slice($backtrace, 2);
47
-		$this->displayDeveloperOutput(
48
-			$errno,
49
-			$errstr,
50
-			$errfile,
51
-			$errline,
52
-			$backtrace
53
-		);
54
-	}
55
-
56
-	/**
57
-	 * handle PHP errors which can't be caught by error-handler
58
-	 */
59
-	public function handleShutdown() {
60
-		$error = error_get_last();
61
-		if ($error === null) {
62
-			return;
63
-		}
64
-		$this->displayDeveloperOutput(
65
-			$error['type'],
66
-			$error['message'],
67
-			$error['file'],
68
-			$error['line']
69
-		);
70
-	}
71
-
72
-	/**
73
-	 * handle all exceptions
74
-	 *
75
-	 * @param \Exception $exception
76
-	 *
77
-	 * @return mixed
78
-	 */
79
-	public function handleException(\Exception $exception) {
80
-		$this->displayDeveloperOutput(
81
-			$exception->getCode(),
82
-			$exception->getMessage(),
83
-			$exception->getFile(),
84
-			$exception->getLine(),
85
-			null,
86
-			$exception
87
-		);
88
-	}
89
-
90
-	/**
91
-	 * show a nice looking and human readable developer output
92
-	 *
93
-	 * @param $code
94
-	 * @param $message
95
-	 * @param $file
96
-	 * @param $line
97
-	 * @param \Exception $exception
98
-	 */
99
-	protected function displayDeveloperOutput($code, $message, $file, $line, array $backtrace = null, \Exception $exception = null) {
100
-		header('HTTP/1.1 500 Internal Server Error');
101
-		$fragment = $this->receiveCodeFragment($file,
102
-			$line, 5, 5);
103
-		$marker = [
104
-			'base_url' => $this->settings['base_url'],
105
-			'type' => $exception ? 'Exception' : 'Error',
106
-			'exception_message' => htmlspecialchars($message),
107
-			'exception_code' => htmlspecialchars($code),
108
-			'exception_file' => htmlspecialchars($file),
109
-			'exception_line' => htmlspecialchars($line),
110
-			'exception_fragment' => $fragment,
111
-			'exception_class' => '',
112
-			'wiki_link' => ''
113
-		];
114
-
115
-		if ($exception) {
116
-			$marker['exception_class'] = $this->linkClass(get_class($exception));
117
-			$marker['wiki_link'] = ($code > 0) ? '(<a href="https://github.com/PhileCMS/Phile/wiki/Exception_' . $code . '" target="_blank">Exception-Wiki</a>)' : '';
118
-			$backtrace = $exception->getTrace();
119
-		}
120
-
121
-		if ($backtrace) {
122
-			$marker['exception_backtrace'] = $this->createBacktrace($backtrace);
123
-		}
124
-
125
-		$DS = DIRECTORY_SEPARATOR;
126
-		$pluginPath = realpath(dirname(__FILE__) . $DS . '..') . $DS;
127
-		$tplPath = $pluginPath . 'template.php';
128
-
129
-		ob_start();
130
-		extract($marker);
131
-		include $tplPath;
132
-		ob_end_flush();
133
-		die();
134
-	}
135
-
136
-	/**
137
-	 * creates a human readable backtrace
138
-	 *
139
-	 * @param array $traces
140
-	 * @return string
141
-	 */
142
-	protected function createBacktrace(array $traces) {
143
-		if (!count($traces)) {
144
-			return '';
145
-		}
146
-		$backtraceCodes = [];
147
-
148
-		foreach ($traces as $index => $step) {
149
-			$backtrace = $this->tag('span', count($traces) - $index, ['class' => 'index']);
150
-			$backtrace .= ' ';
151
-
152
-			if (isset($step['class'])) {
153
-				$class = $this->linkClass($step['class']) . '<span class="divider">::</span>';
154
-				$backtrace .= $class . $this->linkClass($step['class'], $step['function']);
155
-			} elseif (isset($step['function'])) {
156
-				$backtrace .= $this->tag('span', $step['function'], ['class' => 'function']);
157
-			}
158
-
159
-			$arguments = $this->getBacktraceStepArguments($step);
160
-			if ($arguments) {
161
-				$backtrace .= $this->tag('span', "($arguments)", ['class' => 'funcArguments']);
162
-			}
163
-
164
-			if (isset($step['file'])) {
165
-				$backtrace .= $this->receiveCodeFragment($step['file'], $step['line'], 3, 3);
166
-			}
167
-
168
-			$backtraceCodes[] = $this->tag('pre', $backtrace, ['class' => 'entry']);
169
-		}
170
-
171
-		return implode('', $backtraceCodes);
172
-	}
173
-
174
-
175
-	/**
176
-	 * render arguments for backtrace step
177
-	 *
178
-	 * @param $step
179
-	 * @return string
180
-	 */
181
-	protected function getBacktraceStepArguments($step) {
182
-		if (empty($step['args'])) {
183
-			return '';
184
-		}
185
-		$arguments = '';
186
-		foreach ($step['args'] as $argument) {
187
-			$arguments .= strlen($arguments) === 0 ? '' : $this->tag('span', ', ', ['class' => 'separator']);
188
-			if (is_object($argument)) {
189
-				$class = 'class';
190
-				$content = $this->linkClass(get_class($argument));
191
-			} else {
192
-				$class = 'others';
193
-				$content = gettype($argument);
194
-			}
195
-			$arguments .= $this->tag(
196
-				'span',
197
-				$content,
198
-				[
199
-					'class' => $class,
200
-					'title' => print_r($argument, true)
201
-				]
202
-			);
203
-		}
204
-		return $arguments;
205
-	}
206
-
207
-	/**
208
-	 * receive a code fragment from file
209
-	 *
210
-	 * @param $filename
211
-	 * @param $lineNumber
212
-	 * @param $linesBefore
213
-	 * @param $linesAfter
214
-	 *
215
-	 * @return string
216
-	 */
217
-	protected function receiveCodeFragment($filename, $lineNumber, $linesBefore = 3, $linesAfter = 3) {
218
-		if (!file_exists($filename)) {
219
-			return '';
220
-		}
221
-		$html = $this->tag('span', $filename . ':<br/>', ['class' => 'filename']);
222
-
223
-		$code = file_get_contents($filename);
224
-		$lines = explode("\n", $code);
225
-
226
-		$firstLine = $lineNumber - $linesBefore - 1;
227
-		if ($firstLine < 0) {
228
-			$firstLine = 0;
229
-		}
230
-
231
-		$lastLine = $lineNumber + $linesAfter;
232
-		if ($lastLine > count($lines)) {
233
-			$lastLine = count($lines);
234
-		}
235
-
236
-		$line = $firstLine;
237
-		$fragment = '';
238
-		while ($line < $lastLine) {
239
-			$line++;
240
-
241
-			$lineText = htmlspecialchars($lines[$line - 1]);
242
-			$lineText = str_replace("\t", '&nbsp;&nbsp;', $lineText);
243
-			$tmp = sprintf('%05d: %s <br/>', $line, $lineText);
244
-
245
-			$class = 'row';
246
-			if ($line === $lineNumber) {
247
-				$class .= ' currentRow';
248
-			}
249
-			$fragment .= $this->tag('span', $tmp, ['class' => $class]);
250
-		}
251
-
252
-
253
-		$html .= $fragment;
254
-		return $this->tag('pre', $html);
255
-	}
256
-
257
-	/**
258
-	 * link the class or method to the API or return the method name
259
-	 * @param $class
260
-	 * @param $method
261
-	 *
262
-	 * @return string
263
-	 */
264
-	protected function linkClass($class, $method = null) {
265
-		$title = $method ? $method : $class;
266
-		if (strpos($class, 'Phile\\') === 0) {
267
-			return $title;
268
-		}
269
-
270
-		$filename = 'docs/classes/' . str_replace('\\', '.', $class) . '.html';
271
-		if (file_exists(Utility::resolveFilePath($filename))) {
272
-			return $title;
273
-		}
274
-
275
-		$href = $this->settings['base_url'] . '/' . $filename;
276
-		if ($method) {
277
-			$href .= '#method_' . $method;
278
-		}
279
-		return $this->tag('a', $title, ['href' =>  $href, 'target' => '_blank']);
280
-	}
281
-
282
-	/**
283
-	 * create HTML-tag
284
-	 *
285
-	 * @param string $tag
286
-	 * @param string $content
287
-	 * @param array $attributes
288
-	 * @return string
289
-	 */
290
-	protected function tag($tag, $content = '', array $attributes = []) {
291
-		$html = '<' . $tag;
292
-		foreach ($attributes as $key => $value) {
293
-			$html .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
294
-		}
295
-		$html .= '>' . $content . '</' . $tag . '>';
296
-		return $html;
297
-	}
21
+    /** @var array settings */
22
+    protected $settings;
23
+
24
+    /**
25
+     * constructor
26
+     *
27
+     * @param array $settings
28
+     */
29
+    public function __construct(array $settings = []) {
30
+        $this->settings = $settings;
31
+    }
32
+
33
+    /**
34
+     * handle the error
35
+     *
36
+     * @param int    $errno
37
+     * @param string $errstr
38
+     * @param string $errfile
39
+     * @param int    $errline
40
+     * @param array  $errcontext
41
+     *
42
+     * @return boolean
43
+     */
44
+    public function handleError($errno, $errstr, $errfile, $errline, array $errcontext) {
45
+        $backtrace = debug_backtrace();
46
+        $backtrace = array_slice($backtrace, 2);
47
+        $this->displayDeveloperOutput(
48
+            $errno,
49
+            $errstr,
50
+            $errfile,
51
+            $errline,
52
+            $backtrace
53
+        );
54
+    }
55
+
56
+    /**
57
+     * handle PHP errors which can't be caught by error-handler
58
+     */
59
+    public function handleShutdown() {
60
+        $error = error_get_last();
61
+        if ($error === null) {
62
+            return;
63
+        }
64
+        $this->displayDeveloperOutput(
65
+            $error['type'],
66
+            $error['message'],
67
+            $error['file'],
68
+            $error['line']
69
+        );
70
+    }
71
+
72
+    /**
73
+     * handle all exceptions
74
+     *
75
+     * @param \Exception $exception
76
+     *
77
+     * @return mixed
78
+     */
79
+    public function handleException(\Exception $exception) {
80
+        $this->displayDeveloperOutput(
81
+            $exception->getCode(),
82
+            $exception->getMessage(),
83
+            $exception->getFile(),
84
+            $exception->getLine(),
85
+            null,
86
+            $exception
87
+        );
88
+    }
89
+
90
+    /**
91
+     * show a nice looking and human readable developer output
92
+     *
93
+     * @param $code
94
+     * @param $message
95
+     * @param $file
96
+     * @param $line
97
+     * @param \Exception $exception
98
+     */
99
+    protected function displayDeveloperOutput($code, $message, $file, $line, array $backtrace = null, \Exception $exception = null) {
100
+        header('HTTP/1.1 500 Internal Server Error');
101
+        $fragment = $this->receiveCodeFragment($file,
102
+            $line, 5, 5);
103
+        $marker = [
104
+            'base_url' => $this->settings['base_url'],
105
+            'type' => $exception ? 'Exception' : 'Error',
106
+            'exception_message' => htmlspecialchars($message),
107
+            'exception_code' => htmlspecialchars($code),
108
+            'exception_file' => htmlspecialchars($file),
109
+            'exception_line' => htmlspecialchars($line),
110
+            'exception_fragment' => $fragment,
111
+            'exception_class' => '',
112
+            'wiki_link' => ''
113
+        ];
114
+
115
+        if ($exception) {
116
+            $marker['exception_class'] = $this->linkClass(get_class($exception));
117
+            $marker['wiki_link'] = ($code > 0) ? '(<a href="https://github.com/PhileCMS/Phile/wiki/Exception_' . $code . '" target="_blank">Exception-Wiki</a>)' : '';
118
+            $backtrace = $exception->getTrace();
119
+        }
120
+
121
+        if ($backtrace) {
122
+            $marker['exception_backtrace'] = $this->createBacktrace($backtrace);
123
+        }
124
+
125
+        $DS = DIRECTORY_SEPARATOR;
126
+        $pluginPath = realpath(dirname(__FILE__) . $DS . '..') . $DS;
127
+        $tplPath = $pluginPath . 'template.php';
128
+
129
+        ob_start();
130
+        extract($marker);
131
+        include $tplPath;
132
+        ob_end_flush();
133
+        die();
134
+    }
135
+
136
+    /**
137
+     * creates a human readable backtrace
138
+     *
139
+     * @param array $traces
140
+     * @return string
141
+     */
142
+    protected function createBacktrace(array $traces) {
143
+        if (!count($traces)) {
144
+            return '';
145
+        }
146
+        $backtraceCodes = [];
147
+
148
+        foreach ($traces as $index => $step) {
149
+            $backtrace = $this->tag('span', count($traces) - $index, ['class' => 'index']);
150
+            $backtrace .= ' ';
151
+
152
+            if (isset($step['class'])) {
153
+                $class = $this->linkClass($step['class']) . '<span class="divider">::</span>';
154
+                $backtrace .= $class . $this->linkClass($step['class'], $step['function']);
155
+            } elseif (isset($step['function'])) {
156
+                $backtrace .= $this->tag('span', $step['function'], ['class' => 'function']);
157
+            }
158
+
159
+            $arguments = $this->getBacktraceStepArguments($step);
160
+            if ($arguments) {
161
+                $backtrace .= $this->tag('span', "($arguments)", ['class' => 'funcArguments']);
162
+            }
163
+
164
+            if (isset($step['file'])) {
165
+                $backtrace .= $this->receiveCodeFragment($step['file'], $step['line'], 3, 3);
166
+            }
167
+
168
+            $backtraceCodes[] = $this->tag('pre', $backtrace, ['class' => 'entry']);
169
+        }
170
+
171
+        return implode('', $backtraceCodes);
172
+    }
173
+
174
+
175
+    /**
176
+     * render arguments for backtrace step
177
+     *
178
+     * @param $step
179
+     * @return string
180
+     */
181
+    protected function getBacktraceStepArguments($step) {
182
+        if (empty($step['args'])) {
183
+            return '';
184
+        }
185
+        $arguments = '';
186
+        foreach ($step['args'] as $argument) {
187
+            $arguments .= strlen($arguments) === 0 ? '' : $this->tag('span', ', ', ['class' => 'separator']);
188
+            if (is_object($argument)) {
189
+                $class = 'class';
190
+                $content = $this->linkClass(get_class($argument));
191
+            } else {
192
+                $class = 'others';
193
+                $content = gettype($argument);
194
+            }
195
+            $arguments .= $this->tag(
196
+                'span',
197
+                $content,
198
+                [
199
+                    'class' => $class,
200
+                    'title' => print_r($argument, true)
201
+                ]
202
+            );
203
+        }
204
+        return $arguments;
205
+    }
206
+
207
+    /**
208
+     * receive a code fragment from file
209
+     *
210
+     * @param $filename
211
+     * @param $lineNumber
212
+     * @param $linesBefore
213
+     * @param $linesAfter
214
+     *
215
+     * @return string
216
+     */
217
+    protected function receiveCodeFragment($filename, $lineNumber, $linesBefore = 3, $linesAfter = 3) {
218
+        if (!file_exists($filename)) {
219
+            return '';
220
+        }
221
+        $html = $this->tag('span', $filename . ':<br/>', ['class' => 'filename']);
222
+
223
+        $code = file_get_contents($filename);
224
+        $lines = explode("\n", $code);
225
+
226
+        $firstLine = $lineNumber - $linesBefore - 1;
227
+        if ($firstLine < 0) {
228
+            $firstLine = 0;
229
+        }
230
+
231
+        $lastLine = $lineNumber + $linesAfter;
232
+        if ($lastLine > count($lines)) {
233
+            $lastLine = count($lines);
234
+        }
235
+
236
+        $line = $firstLine;
237
+        $fragment = '';
238
+        while ($line < $lastLine) {
239
+            $line++;
240
+
241
+            $lineText = htmlspecialchars($lines[$line - 1]);
242
+            $lineText = str_replace("\t", '&nbsp;&nbsp;', $lineText);
243
+            $tmp = sprintf('%05d: %s <br/>', $line, $lineText);
244
+
245
+            $class = 'row';
246
+            if ($line === $lineNumber) {
247
+                $class .= ' currentRow';
248
+            }
249
+            $fragment .= $this->tag('span', $tmp, ['class' => $class]);
250
+        }
251
+
252
+
253
+        $html .= $fragment;
254
+        return $this->tag('pre', $html);
255
+    }
256
+
257
+    /**
258
+     * link the class or method to the API or return the method name
259
+     * @param $class
260
+     * @param $method
261
+     *
262
+     * @return string
263
+     */
264
+    protected function linkClass($class, $method = null) {
265
+        $title = $method ? $method : $class;
266
+        if (strpos($class, 'Phile\\') === 0) {
267
+            return $title;
268
+        }
269
+
270
+        $filename = 'docs/classes/' . str_replace('\\', '.', $class) . '.html';
271
+        if (file_exists(Utility::resolveFilePath($filename))) {
272
+            return $title;
273
+        }
274
+
275
+        $href = $this->settings['base_url'] . '/' . $filename;
276
+        if ($method) {
277
+            $href .= '#method_' . $method;
278
+        }
279
+        return $this->tag('a', $title, ['href' =>  $href, 'target' => '_blank']);
280
+    }
281
+
282
+    /**
283
+     * create HTML-tag
284
+     *
285
+     * @param string $tag
286
+     * @param string $content
287
+     * @param array $attributes
288
+     * @return string
289
+     */
290
+    protected function tag($tag, $content = '', array $attributes = []) {
291
+        $html = '<' . $tag;
292
+        foreach ($attributes as $key => $value) {
293
+            $html .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
294
+        }
295
+        $html .= '>' . $content . '</' . $tag . '>';
296
+        return $html;
297
+    }
298 298
 }
Please login to merge, or discard this patch.
plugins/phile/errorHandler/Classes/ErrorLog.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The Error Handler
4
- */
3
+     * The Error Handler
4
+     */
5 5
 
6 6
 namespace Phile\Plugin\Phile\ErrorHandler;
7 7
 use Phile\ServiceLocator\ErrorHandlerInterface;
@@ -10,29 +10,29 @@  discard block
 block discarded – undo
10 10
  * Class ErrorLog
11 11
  */
12 12
 class ErrorLog implements ErrorHandlerInterface {
13
-	/**
14
-	 * handle the error
15
-	 *
16
-	 * @param int    $errno
17
-	 * @param string $errstr
18
-	 * @param string $errfile
19
-	 * @param int    $errline
20
-	 * @param array  $errcontext
21
-	 *
22
-	 * @return boolean
23
-	 */
24
-	public function handleError($errno, $errstr, $errfile, $errline, array $errcontext) {
25
-		error_log("[{$errno}] {$errstr} in {$errfile} on line {$errline}");
26
-	}
13
+    /**
14
+     * handle the error
15
+     *
16
+     * @param int    $errno
17
+     * @param string $errstr
18
+     * @param string $errfile
19
+     * @param int    $errline
20
+     * @param array  $errcontext
21
+     *
22
+     * @return boolean
23
+     */
24
+    public function handleError($errno, $errstr, $errfile, $errline, array $errcontext) {
25
+        error_log("[{$errno}] {$errstr} in {$errfile} on line {$errline}");
26
+    }
27 27
 
28
-	/**
29
-	 * handle all exceptions
30
-	 *
31
-	 * @param \Exception $exception
32
-	 *
33
-	 * @return mixed
34
-	 */
35
-	public function handleException(\Exception $exception) {
36
-		error_log("[{$exception->getCode()}] {$exception->getMessage()} in {$exception->getFile()} on line {$exception->getLine()}");
37
-	}
28
+    /**
29
+     * handle all exceptions
30
+     *
31
+     * @param \Exception $exception
32
+     *
33
+     * @return mixed
34
+     */
35
+    public function handleException(\Exception $exception) {
36
+        error_log("[{$exception->getCode()}] {$exception->getMessage()} in {$exception->getFile()} on line {$exception->getLine()}");
37
+    }
38 38
 }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
plugins/phile/errorHandler/Classes/Plugin.php 2 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Plugin class
4
- */
3
+     * Plugin class
4
+     */
5 5
 namespace Phile\Plugin\Phile\ErrorHandler;
6 6
 
7 7
 use Phile\Core\Router;
@@ -20,28 +20,28 @@  discard block
 block discarded – undo
20 20
  * @package Phile\Plugin\Phile\ParserMarkdown
21 21
  */
22 22
 class Plugin extends AbstractPlugin {
23
-	const HANDLER_ERROR_LOG		= 'error_log';
24
-	const HANDLER_DEVELOPMENT	= 'development';
23
+    const HANDLER_ERROR_LOG		= 'error_log';
24
+    const HANDLER_DEVELOPMENT	= 'development';
25 25
 
26
-	protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
26
+    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
27 27
 
28
-	/**
29
-	 * called on 'plugins_loaded' event
30
-	 *
31
-	 * @param null $data
32
-	 * @throws \Phile\Exception\ServiceLocatorException
33
-	 */
34
-	public function onPluginsLoaded($data = null) {
35
-		$this->settings['base_url'] = (new Router)->getBaseUrl();
36
-		switch ($this->settings['handler']) {
37
-			case Plugin::HANDLER_ERROR_LOG:
38
-				ServiceLocator::registerService('Phile_ErrorHandler',
39
-					new ErrorLog($this->settings));
40
-				break;
41
-			case Plugin::HANDLER_DEVELOPMENT:
42
-				ServiceLocator::registerService('Phile_ErrorHandler',
43
-					new Development($this->settings));
44
-				break;
45
-		}
46
-	}
28
+    /**
29
+     * called on 'plugins_loaded' event
30
+     *
31
+     * @param null $data
32
+     * @throws \Phile\Exception\ServiceLocatorException
33
+     */
34
+    public function onPluginsLoaded($data = null) {
35
+        $this->settings['base_url'] = (new Router)->getBaseUrl();
36
+        switch ($this->settings['handler']) {
37
+            case Plugin::HANDLER_ERROR_LOG:
38
+                ServiceLocator::registerService('Phile_ErrorHandler',
39
+                    new ErrorLog($this->settings));
40
+                break;
41
+            case Plugin::HANDLER_DEVELOPMENT:
42
+                ServiceLocator::registerService('Phile_ErrorHandler',
43
+                    new Development($this->settings));
44
+                break;
45
+        }
46
+    }
47 47
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@
 block discarded – undo
20 20
  * @package Phile\Plugin\Phile\ParserMarkdown
21 21
  */
22 22
 class Plugin extends AbstractPlugin {
23
-	const HANDLER_ERROR_LOG		= 'error_log';
24
-	const HANDLER_DEVELOPMENT	= 'development';
23
+	const HANDLER_ERROR_LOG = 'error_log';
24
+	const HANDLER_DEVELOPMENT = 'development';
25 25
 
26 26
 	protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
27 27
 
Please login to merge, or discard this patch.
plugins/phile/errorHandler/config.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * the configuration file
4
- */
3
+     * the configuration file
4
+     */
5 5
 
6 6
 return array(
7
-	'handler' 			=> \Phile\Plugin\Phile\ErrorHandler\Plugin::HANDLER_ERROR_LOG
7
+    'handler' 			=> \Phile\Plugin\Phile\ErrorHandler\Plugin::HANDLER_ERROR_LOG
8 8
 );
Please login to merge, or discard this patch.
plugins/phile/parserMeta/Classes/Plugin.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Plugin class
4
- */
3
+     * Plugin class
4
+     */
5 5
 namespace Phile\Plugin\Phile\ParserMeta;
6 6
 
7 7
 use Phile\Core\ServiceLocator;
@@ -19,18 +19,18 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Plugin extends AbstractPlugin {
21 21
 
22
-	protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
22
+    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
23 23
 
24
-	/**
25
-	 * onPluginsLoaded method
26
-	 *
27
-	 * @param null   $data
28
-	 *
29
-	 * @return mixed|void
30
-	 */
31
-	public function onPluginsLoaded($data = null) {
32
-		ServiceLocator::registerService('Phile_Parser_Meta',
33
-			new Meta($this->settings));
34
-	}
24
+    /**
25
+     * onPluginsLoaded method
26
+     *
27
+     * @param null   $data
28
+     *
29
+     * @return mixed|void
30
+     */
31
+    public function onPluginsLoaded($data = null) {
32
+        ServiceLocator::registerService('Phile_Parser_Meta',
33
+            new Meta($this->settings));
34
+    }
35 35
 
36 36
 }
Please login to merge, or discard this patch.
plugins/phile/parserMeta/Classes/Parser/Meta.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -16,97 +16,97 @@
 block discarded – undo
16 16
  * @package Phile\Plugin\Phile\ParserMeta\Parser
17 17
  */
18 18
 class Meta implements MetaInterface {
19
-	/** @var array $config the configuration for this parser */
20
-	private $config;
19
+    /** @var array $config the configuration for this parser */
20
+    private $config;
21 21
 
22
-	/**
23
-	 * the constructor
24
-	 *
25
-	 * @param array $config
26
-	 */
27
-	public function __construct(array $config = null) {
28
-		if (!is_null($config)) {
29
-			$this->config = $config;
30
-		}
31
-	}
22
+    /**
23
+     * the constructor
24
+     *
25
+     * @param array $config
26
+     */
27
+    public function __construct(array $config = null) {
28
+        if (!is_null($config)) {
29
+            $this->config = $config;
30
+        }
31
+    }
32 32
 
33
-	/**
34
-	 * parse the content and extract meta information
35
-	 *
36
-	 * @param string $rawData raw page data
37
-	 * @return array with key/value store
38
-	 */
39
-	public function parse($rawData) {
40
-		$rawData = trim($rawData);
33
+    /**
34
+     * parse the content and extract meta information
35
+     *
36
+     * @param string $rawData raw page data
37
+     * @return array with key/value store
38
+     */
39
+    public function parse($rawData) {
40
+        $rawData = trim($rawData);
41 41
 
42
-		$start = substr($rawData, 0, 4);
43
-		if ($start === '<!--') {
44
-			$stop = '-->';
45
-		} elseif (substr($start, 0, 2) === '/*') {
46
-			$start = '/*';
47
-			$stop = '*/';
48
-		} else {
49
-			return [];
50
-		}
42
+        $start = substr($rawData, 0, 4);
43
+        if ($start === '<!--') {
44
+            $stop = '-->';
45
+        } elseif (substr($start, 0, 2) === '/*') {
46
+            $start = '/*';
47
+            $stop = '*/';
48
+        } else {
49
+            return [];
50
+        }
51 51
 
52
-		$meta = trim(substr($rawData, strlen($start), strpos($rawData, $stop) - (strlen($stop) + 1)));
53
-		if (strtolower($this->config['format']) === 'yaml') {
54
-			$meta = Yaml::parse($meta);
55
-		} else {
56
-			$meta = $this->parsePhileFormat($meta);
57
-		}
58
-		$meta = ($meta === null) ? [] : $this->convertKeys($meta);
59
-		return $meta;
60
-	}
52
+        $meta = trim(substr($rawData, strlen($start), strpos($rawData, $stop) - (strlen($stop) + 1)));
53
+        if (strtolower($this->config['format']) === 'yaml') {
54
+            $meta = Yaml::parse($meta);
55
+        } else {
56
+            $meta = $this->parsePhileFormat($meta);
57
+        }
58
+        $meta = ($meta === null) ? [] : $this->convertKeys($meta);
59
+        return $meta;
60
+    }
61 61
 
62
-	/**
63
-	 * convert meta data keys
64
-	 *
65
-	 * Creates "compatible" keys allowing easy access e.g. as template var.
66
-	 *
67
-	 * Conversions applied:
68
-	 *
69
-	 * - lowercase all chars
70
-	 * - replace special chars and whitespace with underscore
71
-	 *
72
-	 * @param array $meta meta-data
73
-	 * @return array
74
-	 */
75
-	protected function convertKeys(array $meta) {
76
-		$return = [];
77
-		foreach ($meta as $key => $value) {
78
-			if (is_array($value)) {
79
-				$value = $this->convertKeys($value);
80
-			}
81
-			$newKey = strtolower($key);
82
-			$newKey = preg_replace('/[^\w+]/', '_', $newKey);
83
-			$return[$newKey] = $value;
84
-		}
85
-		return $return;
86
-	}
62
+    /**
63
+     * convert meta data keys
64
+     *
65
+     * Creates "compatible" keys allowing easy access e.g. as template var.
66
+     *
67
+     * Conversions applied:
68
+     *
69
+     * - lowercase all chars
70
+     * - replace special chars and whitespace with underscore
71
+     *
72
+     * @param array $meta meta-data
73
+     * @return array
74
+     */
75
+    protected function convertKeys(array $meta) {
76
+        $return = [];
77
+        foreach ($meta as $key => $value) {
78
+            if (is_array($value)) {
79
+                $value = $this->convertKeys($value);
80
+            }
81
+            $newKey = strtolower($key);
82
+            $newKey = preg_replace('/[^\w+]/', '_', $newKey);
83
+            $return[$newKey] = $value;
84
+        }
85
+        return $return;
86
+    }
87 87
 
88
-	/**
89
-	 * Phile meta format parser.
90
-	 *
91
-	 * @param string $string unparsed meta-data
92
-	 * @return array|null array with meta-tags; null: on meta-data found
93
-	 *
94
-	 * @deprecated since 1.6.0 Phile is going to switch to YAML
95
-	 */
96
-	protected function parsePhileFormat($string) {
97
-		if (empty($string)) {
98
-			return null;
99
-		}
100
-		$meta = [];
101
-		$lines = explode("\n", $string);
102
-		foreach ($lines as $line) {
103
-			$parts = explode(':', $line, 2);
104
-			if (count($parts) !== 2) {
105
-				continue;
106
-			}
107
-			$parts = array_map('trim', $parts);
108
-			$meta[$parts[0]] = $parts[1];
109
-		}
110
-		return $meta;
111
-	}
88
+    /**
89
+     * Phile meta format parser.
90
+     *
91
+     * @param string $string unparsed meta-data
92
+     * @return array|null array with meta-tags; null: on meta-data found
93
+     *
94
+     * @deprecated since 1.6.0 Phile is going to switch to YAML
95
+     */
96
+    protected function parsePhileFormat($string) {
97
+        if (empty($string)) {
98
+            return null;
99
+        }
100
+        $meta = [];
101
+        $lines = explode("\n", $string);
102
+        foreach ($lines as $line) {
103
+            $parts = explode(':', $line, 2);
104
+            if (count($parts) !== 2) {
105
+                continue;
106
+            }
107
+            $parts = array_map('trim', $parts);
108
+            $meta[$parts[0]] = $parts[1];
109
+        }
110
+        return $meta;
111
+    }
112 112
 }
Please login to merge, or discard this patch.
plugins/phile/parserMarkdown/Classes/Plugin.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Plugin class
4
- */
3
+     * Plugin class
4
+     */
5 5
 namespace Phile\Plugin\Phile\ParserMarkdown;
6 6
 
7 7
 use Phile\Core\ServiceLocator;
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class Plugin extends AbstractPlugin {
21 21
 
22
-	protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
22
+    protected $events = ['plugins_loaded' => 'onPluginsLoaded'];
23 23
 
24
-	/**
25
-	 * onPluginsLoaded method
26
-	 *
27
-	 * @param null   $data
28
-	 *
29
-	 * @return mixed|void
30
-	 */
31
-	public function onPluginsLoaded($data = null) {
32
-		ServiceLocator::registerService('Phile_Parser', new Markdown($this->settings));
33
-	}
24
+    /**
25
+     * onPluginsLoaded method
26
+     *
27
+     * @param null   $data
28
+     *
29
+     * @return mixed|void
30
+     */
31
+    public function onPluginsLoaded($data = null) {
32
+        ServiceLocator::registerService('Phile_Parser', new Markdown($this->settings));
33
+    }
34 34
 }
Please login to merge, or discard this patch.
plugins/phile/parserMarkdown/Classes/Parser/Markdown.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * The Mardown parser class
4
- */
3
+     * The Mardown parser class
4
+     */
5 5
 namespace Phile\Plugin\Phile\ParserMarkdown\Parser;
6 6
 
7 7
 use Michelf\MarkdownExtra;
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
  * @package Phile\Plugin\Phile\ParserMarkdown\Parser
17 17
  */
18 18
 class Markdown implements ParserInterface {
19
-	/** @var mixed the configuration */
20
-	private $config;
19
+    /** @var mixed the configuration */
20
+    private $config;
21 21
 
22
-	/**
23
-	 * the constructor
24
-	 *
25
-	 * @param null $config
26
-	 */
27
-	public function __construct($config = null) {
28
-		if (!is_null($config)) {
29
-			$this->config = $config;
30
-		}
31
-	}
22
+    /**
23
+     * the constructor
24
+     *
25
+     * @param null $config
26
+     */
27
+    public function __construct($config = null) {
28
+        if (!is_null($config)) {
29
+            $this->config = $config;
30
+        }
31
+    }
32 32
 
33
-	/**
34
-	 * overload parse with the MarkdownExtra parser
35
-	 *
36
-	 * @param $data
37
-	 *
38
-	 * @return string
39
-	 */
40
-	public function parse($data) {
41
-		$parser = new MarkdownExtra;
42
-		foreach ($this->config as $key => $value) {
43
-			$parser->{$key} = $value;
44
-		}
33
+    /**
34
+     * overload parse with the MarkdownExtra parser
35
+     *
36
+     * @param $data
37
+     *
38
+     * @return string
39
+     */
40
+    public function parse($data) {
41
+        $parser = new MarkdownExtra;
42
+        foreach ($this->config as $key => $value) {
43
+            $parser->{$key} = $value;
44
+        }
45 45
 
46
-		return $parser->transform($data);
47
-	}
46
+        return $parser->transform($data);
47
+    }
48 48
 }
Please login to merge, or discard this patch.
plugins/phile/parserMarkdown/config.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * the configuration file
4
- *
5
- * @see https://michelf.ca/projects/php-markdown/configuration/
6
- */
3
+     * the configuration file
4
+     *
5
+     * @see https://michelf.ca/projects/php-markdown/configuration/
6
+     */
7 7
 
8 8
 return array(
9
-	'empty_element_suffix' => ' />',
10
-	'tab_width'            => 4,
11
-	'no_markup'            => false,
12
-	'no_entities'          => false,
13
-	'predef_urls'          => array(
14
-		'base_url' => \Phile\Core\Utility::getBaseUrl() // base_url is a good reference to have
15
-	),
16
-	'predef_titles'        => array(),
17
-	'fn_id_prefix'         => "",
18
-	'fn_link_title'        => "",
19
-	'fn_backlink_title'    => "",
20
-	'fn_link_class'        => "footnote-ref",
21
-	'fn_backlink_class'    => "footnote-backref",
22
-	'code_class_prefix'    => "",
23
-	'code_attr_on_pre'     => false,
24
-	'predef_abbr'          => array()
9
+    'empty_element_suffix' => ' />',
10
+    'tab_width'            => 4,
11
+    'no_markup'            => false,
12
+    'no_entities'          => false,
13
+    'predef_urls'          => array(
14
+        'base_url' => \Phile\Core\Utility::getBaseUrl() // base_url is a good reference to have
15
+    ),
16
+    'predef_titles'        => array(),
17
+    'fn_id_prefix'         => "",
18
+    'fn_link_title'        => "",
19
+    'fn_backlink_title'    => "",
20
+    'fn_link_class'        => "footnote-ref",
21
+    'fn_backlink_class'    => "footnote-backref",
22
+    'code_class_prefix'    => "",
23
+    'code_attr_on_pre'     => false,
24
+    'predef_abbr'          => array()
25 25
 );
Please login to merge, or discard this patch.