@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $this->text = preg_replace_callback('%\[size=\d*\]([\W\D\w\s]*?)\[/size\]%iu', |
27 | 27 | |
28 | - function ($matches) { |
|
28 | + function($matches) { |
|
29 | 29 | return $matches[1]; |
30 | 30 | }, |
31 | 31 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $this->text = preg_replace_callback('%\[center\]([\W\D\w\s]*?)\[/center\]%iu', |
45 | 45 | |
46 | - function ($matches) { |
|
46 | + function($matches) { |
|
47 | 47 | return $matches[1]; |
48 | 48 | }, |
49 | 49 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | $this->text = preg_replace_callback('%\[left\]([\W\D\w\s]*?)\[/left\]%iu', |
63 | 63 | |
64 | - function ($matches) { |
|
64 | + function($matches) { |
|
65 | 65 | return $matches[1]; |
66 | 66 | }, |
67 | 67 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $this->text = preg_replace_callback('%\[color[=?][#?][\w]*\]([\W\D\w\s]*?)\[/color\]%iu', |
80 | 80 | |
81 | - function ($matches) { |
|
81 | + function($matches) { |
|
82 | 82 | return $matches[1]; |
83 | 83 | }, |
84 | 84 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | |
97 | 97 | $this->text = preg_replace_callback('%\[b\]([\W\D\w\s]*?)\[/b\]%iu', |
98 | 98 | |
99 | - function ($matches) { |
|
100 | - return "**" . trim($matches[1], " ") . "**"; |
|
99 | + function($matches) { |
|
100 | + return "**".trim($matches[1], " ")."**"; |
|
101 | 101 | }, |
102 | 102 | |
103 | 103 | $this->text |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | |
115 | 115 | $this->text = preg_replace_callback('%\[i\]([\W\D\w\s]*?)\[/i\]%iu', |
116 | 116 | |
117 | - function ($matches) { |
|
118 | - return "*" . trim($matches[1], " ") . "*"; |
|
117 | + function($matches) { |
|
118 | + return "*".trim($matches[1], " ")."*"; |
|
119 | 119 | }, |
120 | 120 | |
121 | 121 | $this->text |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | |
133 | 133 | $this->text = preg_replace_callback('%\[u\]([\W\D\w\s]*?)\[/u\]%iu', |
134 | 134 | |
135 | - function ($matches) { |
|
136 | - return "_" . trim($matches[1], " ") . "_"; |
|
135 | + function($matches) { |
|
136 | + return "_".trim($matches[1], " ")."_"; |
|
137 | 137 | }, |
138 | 138 | |
139 | 139 | $this->text |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | |
151 | 151 | $this->text = preg_replace_callback('%\[s\]([\W\D\w\s]*?)\[/s\]%iu', |
152 | 152 | |
153 | - function ($matches) { |
|
154 | - return "~~" . trim($matches[1], " ") . "~~"; |
|
153 | + function($matches) { |
|
154 | + return "~~".trim($matches[1], " ")."~~"; |
|
155 | 155 | }, |
156 | 156 | |
157 | 157 | $this->text |
@@ -168,32 +168,32 @@ discard block |
||
168 | 168 | |
169 | 169 | $this->text = preg_replace_callback('%\[list(?P<type>=1)?\](?P<items>[\W\D\w\s]*?)\[/list\]%iu', |
170 | 170 | |
171 | - function ($matches) { |
|
171 | + function($matches) { |
|
172 | 172 | $buffer = ""; |
173 | 173 | |
174 | 174 | $list = preg_replace('/\s*$|^\s*/mu', '', $matches['items']); |
175 | - if ( is_null($list) ) |
|
175 | + if (is_null($list)) |
|
176 | 176 | throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode lists", $this->id)); |
177 | 177 | |
178 | 178 | $items = preg_split('/\[\*\]/u', $list); |
179 | 179 | |
180 | 180 | $counter = count($items); |
181 | 181 | |
182 | - if ( isset($matches['type']) && $matches['type'] == '=1' ) { // ordered list |
|
182 | + if (isset($matches['type']) && $matches['type'] == '=1') { // ordered list |
|
183 | 183 | // We start from 1 to discard the first string, in fact, it's empty. |
184 | - for ( $i = 1; $i < $counter; $i++ ) |
|
185 | - if ( !empty($items[ $i ]) ) |
|
186 | - $buffer .= (string) ( $i ) . '. ' . trim($items[ $i ]) . PHP_EOL; |
|
184 | + for ($i = 1; $i < $counter; $i++) |
|
185 | + if (!empty($items[$i])) |
|
186 | + $buffer .= (string)($i).'. '.trim($items[$i]).PHP_EOL; |
|
187 | 187 | } else { // unordered list |
188 | 188 | // We start from 1 to discard the first string, in fact, it's empty. |
189 | - for ( $i = 1; $i < $counter; $i++ ) |
|
190 | - if ( !empty($items[ $i ]) ) |
|
191 | - $buffer .= '- ' . trim($items[ $i ]) . PHP_EOL; |
|
189 | + for ($i = 1; $i < $counter; $i++) |
|
190 | + if (!empty($items[$i])) |
|
191 | + $buffer .= '- '.trim($items[$i]).PHP_EOL; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | // We need a like break above the list and another one below. |
195 | - if ( !empty($buffer) ) |
|
196 | - $buffer = PHP_EOL . $buffer . PHP_EOL; |
|
195 | + if (!empty($buffer)) |
|
196 | + $buffer = PHP_EOL.$buffer.PHP_EOL; |
|
197 | 197 | |
198 | 198 | return $buffer; |
199 | 199 | }, |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | |
213 | 213 | $this->text = preg_replace_callback('%\[url\s*=\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\]([\W\D\w\s]*?)\[/url\]%iu', |
214 | 214 | |
215 | - function ($matches) { |
|
216 | - if ( isset($matches[1]) && isset($matches[2]) ) |
|
217 | - return "[" . $matches[2] . "](" . $matches[1] . ")"; |
|
215 | + function($matches) { |
|
216 | + if (isset($matches[1]) && isset($matches[2])) |
|
217 | + return "[".$matches[2]."](".$matches[1].")"; |
|
218 | 218 | else |
219 | 219 | throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
220 | 220 | }, |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | { |
233 | 233 | $this->text = preg_replace_callback('%\[url\]([\W\D\w\s]*?)\[/url\]%iu', |
234 | 234 | |
235 | - function ($matches) { |
|
236 | - if ( isset($matches[1]) ) |
|
237 | - return "[" . $matches[1] . "](" . $matches[1] . ")"; |
|
235 | + function($matches) { |
|
236 | + if (isset($matches[1])) |
|
237 | + return "[".$matches[1]."](".$matches[1].")"; |
|
238 | 238 | else |
239 | 239 | throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
240 | 240 | }, |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | |
254 | 254 | $this->text = preg_replace_callback('%\[img\s*\]\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\[/img\]%iu', |
255 | 255 | |
256 | - function ($matches) { |
|
257 | - if ( isset($matches[1]) ) |
|
258 | - return PHP_EOL . "![]" . "(" . $matches[1] . ")" . PHP_EOL; |
|
256 | + function($matches) { |
|
257 | + if (isset($matches[1])) |
|
258 | + return PHP_EOL."![]"."(".$matches[1].")".PHP_EOL; |
|
259 | 259 | else |
260 | 260 | throw new \RuntimeException(sprintf("Text identified by '%d' have malformed BBCode images", $this->id)); |
261 | 261 | }, |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | // Replaces all the remaining quotes with '> ' characters. |
279 | 279 | $this->text = preg_replace_callback('%\[quote\b[^]]*\]((?>[^[]++|\[(?!/?quote))*)\[/quote\]%i', |
280 | 280 | |
281 | - function ($matches) { |
|
281 | + function($matches) { |
|
282 | 282 | $quote = preg_replace('/^\s*/mu', '', trim($matches[1])); |
283 | - return "> " . $quote . PHP_EOL . PHP_EOL; |
|
283 | + return "> ".$quote.PHP_EOL.PHP_EOL; |
|
284 | 284 | }, |
285 | 285 | |
286 | 286 | $this->text |
@@ -296,36 +296,36 @@ discard block |
||
296 | 296 | |
297 | 297 | $this->text = preg_replace_callback('%\[code\s*=?(?P<language>\w*)\](?P<snippet>[\W\D\w\s]*?)\[\/code\]%iu', |
298 | 298 | |
299 | - function ($matches) { |
|
300 | - if ( isset($matches['snippet']) ) { |
|
299 | + function($matches) { |
|
300 | + if (isset($matches['snippet'])) { |
|
301 | 301 | $language = strtolower($matches['language']); |
302 | 302 | |
303 | - if ( $language == 'html4strict' or $language == 'div' ) |
|
303 | + if ($language == 'html4strict' or $language == 'div') |
|
304 | 304 | $language = 'html'; |
305 | - elseif ( $language == 'shell' or $language == 'dos' or $language == 'batch' ) |
|
305 | + elseif ($language == 'shell' or $language == 'dos' or $language == 'batch') |
|
306 | 306 | $language = 'sh'; |
307 | - elseif ( $language == 'xul' or $language == 'wpf' ) |
|
307 | + elseif ($language == 'xul' or $language == 'wpf') |
|
308 | 308 | $language = 'xml'; |
309 | - elseif ( $language == 'asm' ) |
|
309 | + elseif ($language == 'asm') |
|
310 | 310 | $language = 'nasm'; |
311 | - elseif ( $language == 'vb' or $language == 'visualbasic' or $language == 'vba' ) |
|
311 | + elseif ($language == 'vb' or $language == 'visualbasic' or $language == 'vba') |
|
312 | 312 | $language = 'vb.net'; |
313 | - elseif ( $language == 'asp' ) |
|
313 | + elseif ($language == 'asp') |
|
314 | 314 | $language = 'aspx-vb'; |
315 | - elseif ( $language == 'xaml' ) |
|
315 | + elseif ($language == 'xaml') |
|
316 | 316 | $language = 'xml'; |
317 | - elseif ( $language == 'cplusplus' ) |
|
317 | + elseif ($language == 'cplusplus') |
|
318 | 318 | $language = 'cpp'; |
319 | - elseif ( $language == 'txt' or $language == 'gettext' ) |
|
319 | + elseif ($language == 'txt' or $language == 'gettext') |
|
320 | 320 | $language = 'text'; |
321 | - elseif ( $language == 'basic' ) |
|
321 | + elseif ($language == 'basic') |
|
322 | 322 | $language = 'cbmbas'; |
323 | - elseif ( $language == 'lisp' ) |
|
323 | + elseif ($language == 'lisp') |
|
324 | 324 | $language = 'clojure'; |
325 | - elseif ( $language == 'aspnet' ) |
|
325 | + elseif ($language == 'aspnet') |
|
326 | 326 | $language = 'aspx-vb'; |
327 | 327 | |
328 | - return PHP_EOL . "```" . $language . PHP_EOL . trim($matches['snippet']) . PHP_EOL . "```" . PHP_EOL; |
|
328 | + return PHP_EOL."```".$language.PHP_EOL.trim($matches['snippet']).PHP_EOL."```".PHP_EOL; |
|
329 | 329 | } else |
330 | 330 | throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode snippet.", $this->id)); |
331 | 331 | }, |
@@ -172,8 +172,9 @@ discard block |
||
172 | 172 | $buffer = ""; |
173 | 173 | |
174 | 174 | $list = preg_replace('/\s*$|^\s*/mu', '', $matches['items']); |
175 | - if ( is_null($list) ) |
|
176 | - throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode lists", $this->id)); |
|
175 | + if ( is_null($list) ) { |
|
176 | + throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode lists", $this->id)); |
|
177 | + } |
|
177 | 178 | |
178 | 179 | $items = preg_split('/\[\*\]/u', $list); |
179 | 180 | |
@@ -181,19 +182,22 @@ discard block |
||
181 | 182 | |
182 | 183 | if ( isset($matches['type']) && $matches['type'] == '=1' ) { // ordered list |
183 | 184 | // We start from 1 to discard the first string, in fact, it's empty. |
184 | - for ( $i = 1; $i < $counter; $i++ ) |
|
185 | - if ( !empty($items[ $i ]) ) |
|
185 | + for ( $i = 1; $i < $counter; $i++ ) { |
|
186 | + if ( !empty($items[ $i ]) ) |
|
186 | 187 | $buffer .= (string) ( $i ) . '. ' . trim($items[ $i ]) . PHP_EOL; |
188 | + } |
|
187 | 189 | } else { // unordered list |
188 | 190 | // We start from 1 to discard the first string, in fact, it's empty. |
189 | - for ( $i = 1; $i < $counter; $i++ ) |
|
190 | - if ( !empty($items[ $i ]) ) |
|
191 | + for ( $i = 1; $i < $counter; $i++ ) { |
|
192 | + if ( !empty($items[ $i ]) ) |
|
191 | 193 | $buffer .= '- ' . trim($items[ $i ]) . PHP_EOL; |
194 | + } |
|
192 | 195 | } |
193 | 196 | |
194 | 197 | // We need a like break above the list and another one below. |
195 | - if ( !empty($buffer) ) |
|
196 | - $buffer = PHP_EOL . $buffer . PHP_EOL; |
|
198 | + if ( !empty($buffer) ) { |
|
199 | + $buffer = PHP_EOL . $buffer . PHP_EOL; |
|
200 | + } |
|
197 | 201 | |
198 | 202 | return $buffer; |
199 | 203 | }, |
@@ -213,10 +217,11 @@ discard block |
||
213 | 217 | $this->text = preg_replace_callback('%\[url\s*=\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\]([\W\D\w\s]*?)\[/url\]%iu', |
214 | 218 | |
215 | 219 | function ($matches) { |
216 | - if ( isset($matches[1]) && isset($matches[2]) ) |
|
217 | - return "[" . $matches[2] . "](" . $matches[1] . ")"; |
|
218 | - else |
|
219 | - throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
|
220 | + if ( isset($matches[1]) && isset($matches[2]) ) { |
|
221 | + return "[" . $matches[2] . "](" . $matches[1] . ")"; |
|
222 | + } else { |
|
223 | + throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
|
224 | + } |
|
220 | 225 | }, |
221 | 226 | |
222 | 227 | $this->text |
@@ -233,10 +238,11 @@ discard block |
||
233 | 238 | $this->text = preg_replace_callback('%\[url\]([\W\D\w\s]*?)\[/url\]%iu', |
234 | 239 | |
235 | 240 | function ($matches) { |
236 | - if ( isset($matches[1]) ) |
|
237 | - return "[" . $matches[1] . "](" . $matches[1] . ")"; |
|
238 | - else |
|
239 | - throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
|
241 | + if ( isset($matches[1]) ) { |
|
242 | + return "[" . $matches[1] . "](" . $matches[1] . ")"; |
|
243 | + } else { |
|
244 | + throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
|
245 | + } |
|
240 | 246 | }, |
241 | 247 | |
242 | 248 | $this->text |
@@ -254,10 +260,11 @@ discard block |
||
254 | 260 | $this->text = preg_replace_callback('%\[img\s*\]\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\[/img\]%iu', |
255 | 261 | |
256 | 262 | function ($matches) { |
257 | - if ( isset($matches[1]) ) |
|
258 | - return PHP_EOL . "![]" . "(" . $matches[1] . ")" . PHP_EOL; |
|
259 | - else |
|
260 | - throw new \RuntimeException(sprintf("Text identified by '%d' have malformed BBCode images", $this->id)); |
|
263 | + if ( isset($matches[1]) ) { |
|
264 | + return PHP_EOL . "![]" . "(" . $matches[1] . ")" . PHP_EOL; |
|
265 | + } else { |
|
266 | + throw new \RuntimeException(sprintf("Text identified by '%d' have malformed BBCode images", $this->id)); |
|
267 | + } |
|
261 | 268 | }, |
262 | 269 | |
263 | 270 | $this->text |
@@ -300,34 +307,36 @@ discard block |
||
300 | 307 | if ( isset($matches['snippet']) ) { |
301 | 308 | $language = strtolower($matches['language']); |
302 | 309 | |
303 | - if ( $language == 'html4strict' or $language == 'div' ) |
|
304 | - $language = 'html'; |
|
305 | - elseif ( $language == 'shell' or $language == 'dos' or $language == 'batch' ) |
|
306 | - $language = 'sh'; |
|
307 | - elseif ( $language == 'xul' or $language == 'wpf' ) |
|
308 | - $language = 'xml'; |
|
309 | - elseif ( $language == 'asm' ) |
|
310 | - $language = 'nasm'; |
|
311 | - elseif ( $language == 'vb' or $language == 'visualbasic' or $language == 'vba' ) |
|
312 | - $language = 'vb.net'; |
|
313 | - elseif ( $language == 'asp' ) |
|
314 | - $language = 'aspx-vb'; |
|
315 | - elseif ( $language == 'xaml' ) |
|
316 | - $language = 'xml'; |
|
317 | - elseif ( $language == 'cplusplus' ) |
|
318 | - $language = 'cpp'; |
|
319 | - elseif ( $language == 'txt' or $language == 'gettext' ) |
|
320 | - $language = 'text'; |
|
321 | - elseif ( $language == 'basic' ) |
|
322 | - $language = 'cbmbas'; |
|
323 | - elseif ( $language == 'lisp' ) |
|
324 | - $language = 'clojure'; |
|
325 | - elseif ( $language == 'aspnet' ) |
|
326 | - $language = 'aspx-vb'; |
|
310 | + if ( $language == 'html4strict' or $language == 'div' ) { |
|
311 | + $language = 'html'; |
|
312 | + } elseif ( $language == 'shell' or $language == 'dos' or $language == 'batch' ) { |
|
313 | + $language = 'sh'; |
|
314 | + } elseif ( $language == 'xul' or $language == 'wpf' ) { |
|
315 | + $language = 'xml'; |
|
316 | + } elseif ( $language == 'asm' ) { |
|
317 | + $language = 'nasm'; |
|
318 | + } elseif ( $language == 'vb' or $language == 'visualbasic' or $language == 'vba' ) { |
|
319 | + $language = 'vb.net'; |
|
320 | + } elseif ( $language == 'asp' ) { |
|
321 | + $language = 'aspx-vb'; |
|
322 | + } elseif ( $language == 'xaml' ) { |
|
323 | + $language = 'xml'; |
|
324 | + } elseif ( $language == 'cplusplus' ) { |
|
325 | + $language = 'cpp'; |
|
326 | + } elseif ( $language == 'txt' or $language == 'gettext' ) { |
|
327 | + $language = 'text'; |
|
328 | + } elseif ( $language == 'basic' ) { |
|
329 | + $language = 'cbmbas'; |
|
330 | + } elseif ( $language == 'lisp' ) { |
|
331 | + $language = 'clojure'; |
|
332 | + } elseif ( $language == 'aspnet' ) { |
|
333 | + $language = 'aspx-vb'; |
|
334 | + } |
|
327 | 335 | |
328 | 336 | return PHP_EOL . "```" . $language . PHP_EOL . trim($matches['snippet']) . PHP_EOL . "```" . PHP_EOL; |
329 | - } else |
|
330 | - throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode snippet.", $this->id)); |
|
337 | + } else { |
|
338 | + throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode snippet.", $this->id)); |
|
339 | + } |
|
331 | 340 | }, |
332 | 341 | |
333 | 342 | $this->text |