@@ -48,8 +48,8 @@ |
||
48 | 48 | if ($this->isSupported()) { |
49 | 49 | $this->engine = \cebe\markdown\Markdown(); |
50 | 50 | |
51 | - if (isset($config[ 'flavour' ])) { |
|
52 | - $this->setFlavour($config[ 'flavour' ]); |
|
51 | + if (isset($config['flavour'])) { |
|
52 | + $this->setFlavour($config['flavour']); |
|
53 | 53 | } |
54 | 54 | } else { |
55 | 55 | throw new BadThirdPartyException( |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | $driverClassName = '\O2System\Parser\Drivers\\' . ucfirst($driverOffset) . 'Driver'; |
101 | 101 | |
102 | 102 | if (class_exists($driverClassName)) { |
103 | - if (isset($config[ 'engine' ])) { |
|
104 | - unset($config[ 'engine' ]); |
|
103 | + if (isset($config['engine'])) { |
|
104 | + unset($config['engine']); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | $this->register((new $driverClassName())->initialize($config), $driverOffset); |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | $driverOffset = strtolower($driverOffset); |
119 | 119 | |
120 | 120 | if ($this->config->offsetExists($driverOffset)) { |
121 | - $config = $this->config[ $driverOffset ]; |
|
121 | + $config = $this->config[$driverOffset]; |
|
122 | 122 | } else { |
123 | 123 | $config = $this->config->getArrayCopy(); |
124 | 124 | } |
125 | 125 | |
126 | - if (isset($config[ 'engine' ])) { |
|
127 | - unset($config[ 'engine' ]); |
|
126 | + if (isset($config['engine'])) { |
|
127 | + unset($config['engine']); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if ($driver->isInitialize()) { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | continue; |
213 | 213 | } |
214 | 214 | |
215 | - $engine =& $driverEngine->getEngine(); |
|
215 | + $engine = & $driverEngine->getEngine(); |
|
216 | 216 | |
217 | 217 | if ($engine instanceof ParserEngineInterface) { |
218 | 218 | $engine->addFilePath($this->sourceFileDirectory); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | */ |
246 | 246 | ob_start(); |
247 | 247 | |
248 | - echo eval('?>' . str_replace([';?>',')?>', ');?>'], ['; ?>','); ?>', '); ?>'], $this->sourceString)); |
|
248 | + echo eval('?>' . str_replace([';?>', ')?>', ');?>'], ['; ?>', '); ?>', '); ?>'], $this->sourceString)); |
|
249 | 249 | |
250 | 250 | $output = ob_get_contents(); |
251 | 251 | @ob_end_clean(); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $inString = 0; |
306 | 306 | foreach (token_get_all('<?php ' . $sourceCode) as $token) { |
307 | 307 | if (is_array($token)) { |
308 | - switch ($token[ 0 ]) { |
|
308 | + switch ($token[0]) { |
|
309 | 309 | case T_CURLY_OPEN: |
310 | 310 | case T_DOLLAR_OPEN_CURLY_BRACES: |
311 | 311 | case T_START_HEREDOC: |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | $sourceCode = ob_get_clean(); |
364 | 364 | $sourceCode = strip_tags($sourceCode); |
365 | 365 | if (preg_match("'syntax error, (.+) in .+ on line (\d+)$'s", $sourceCode, $sourceCode)) { |
366 | - $sourceCode[ 2 ] = (int)$sourceCode[ 2 ]; |
|
367 | - $sourceCode = $sourceCode[ 2 ] <= $braces |
|
368 | - ? [$sourceCode[ 1 ], $sourceCode[ 2 ]] |
|
369 | - : ['unexpected $end' . substr($sourceCode[ 1 ], 14), $braces]; |
|
366 | + $sourceCode[2] = (int)$sourceCode[2]; |
|
367 | + $sourceCode = $sourceCode[2] <= $braces |
|
368 | + ? [$sourceCode[1], $sourceCode[2]] |
|
369 | + : ['unexpected $end' . substr($sourceCode[1], 14), $braces]; |
|
370 | 370 | } else { |
371 | 371 | $sourceCode = ['syntax error', 0]; |
372 | 372 | } |
@@ -162,25 +162,25 @@ discard block |
||
162 | 162 | private function parseRegex($match) |
163 | 163 | { |
164 | 164 | // allow [[foo]] syntax for escaping a tag |
165 | - if ($match[ 1 ] == '[' && $match[ 6 ] == ']') { |
|
166 | - return substr($match[ 0 ], 1, -1); |
|
165 | + if ($match[1] == '[' && $match[6] == ']') { |
|
166 | + return substr($match[0], 1, -1); |
|
167 | 167 | } |
168 | 168 | |
169 | - $offset = $match[ 2 ]; |
|
170 | - $attr = $this->parseRegexAttributes($match[ 3 ]); |
|
169 | + $offset = $match[2]; |
|
170 | + $attr = $this->parseRegexAttributes($match[3]); |
|
171 | 171 | |
172 | 172 | if ($this->exists($offset)) { |
173 | - if (isset($match[ 5 ])) { |
|
173 | + if (isset($match[5])) { |
|
174 | 174 | // enclosing tag - extra parameter |
175 | - return $match[ 1 ] . call_user_func( |
|
175 | + return $match[1] . call_user_func( |
|
176 | 176 | $this->__get($offset), |
177 | 177 | $attr, |
178 | - $match[ 5 ], |
|
178 | + $match[5], |
|
179 | 179 | $offset |
180 | - ) . $match[ 6 ]; |
|
180 | + ) . $match[6]; |
|
181 | 181 | } else { |
182 | 182 | // self-closing tag |
183 | - return $match[ 1 ] . call_user_func($this->__get($offset), $attr, null, $offset) . $match[ 6 ]; |
|
183 | + return $match[1] . call_user_func($this->__get($offset), $attr, null, $offset) . $match[6]; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
@@ -209,16 +209,16 @@ discard block |
||
209 | 209 | $string = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $string); |
210 | 210 | if (preg_match_all($pattern, $string, $match, PREG_SET_ORDER)) { |
211 | 211 | foreach ($match as $m) { |
212 | - if ( ! empty($m[ 1 ])) { |
|
213 | - $attr[ strtolower($m[ 1 ]) ] = stripcslashes($m[ 2 ]); |
|
214 | - } elseif ( ! empty($m[ 3 ])) { |
|
215 | - $attr[ strtolower($m[ 3 ]) ] = stripcslashes($m[ 4 ]); |
|
216 | - } elseif ( ! empty($m[ 5 ])) { |
|
217 | - $attr[ strtolower($m[ 5 ]) ] = stripcslashes($m[ 6 ]); |
|
218 | - } elseif (isset($m[ 7 ]) and strlen($m[ 7 ])) { |
|
219 | - $attr[] = stripcslashes($m[ 7 ]); |
|
220 | - } elseif (isset($m[ 8 ])) { |
|
221 | - $attr[] = stripcslashes($m[ 8 ]); |
|
212 | + if ( ! empty($m[1])) { |
|
213 | + $attr[strtolower($m[1])] = stripcslashes($m[2]); |
|
214 | + } elseif ( ! empty($m[3])) { |
|
215 | + $attr[strtolower($m[3])] = stripcslashes($m[4]); |
|
216 | + } elseif ( ! empty($m[5])) { |
|
217 | + $attr[strtolower($m[5])] = stripcslashes($m[6]); |
|
218 | + } elseif (isset($m[7]) and strlen($m[7])) { |
|
219 | + $attr[] = stripcslashes($m[7]); |
|
220 | + } elseif (isset($m[8])) { |
|
221 | + $attr[] = stripcslashes($m[8]); |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | } else { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | public function parseString($string, array $vars = []) |
82 | 82 | { |
83 | - $this->vars =& $vars; |
|
83 | + $this->vars = & $vars; |
|
84 | 84 | |
85 | 85 | // Collect sections with no closing |
86 | 86 | $string = preg_replace_callback('/@section((.*),(.*))/', [&$this, 'collectSection'], $string); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | private function replaceString($string) |
132 | 132 | { |
133 | - if ($this->config[ 'allowPhpGlobals' ] === false) { |
|
133 | + if ($this->config['allowPhpGlobals'] === false) { |
|
134 | 134 | $string = str_replace( |
135 | 135 | [ |
136 | 136 | '{{$GLOBALS}}', |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | '@choice( %%,%% )' => '@choice not supported', |
252 | 252 | ]; |
253 | 253 | |
254 | - if ($this->config[ 'allowPhpFunctions' ] === false) { |
|
255 | - $functionsCodes[ '@%%(%%)' ] = ''; |
|
256 | - } elseif (is_array($this->config[ 'allowPhpFunctions' ]) AND count( |
|
257 | - $this->config[ 'allowPhpFunctions' ] |
|
254 | + if ($this->config['allowPhpFunctions'] === false) { |
|
255 | + $functionsCodes['@%%(%%)'] = ''; |
|
256 | + } elseif (is_array($this->config['allowPhpFunctions']) AND count( |
|
257 | + $this->config['allowPhpFunctions'] |
|
258 | 258 | ) > 0 |
259 | 259 | ) { |
260 | - foreach ($this->config[ 'allowPhpFunctions' ] as $functionName) { |
|
261 | - $functionsCodes[ '@' . $functionName . '(%%)' ] = '<?php echo ' . $functionName . '(\1); ?>'; |
|
260 | + foreach ($this->config['allowPhpFunctions'] as $functionName) { |
|
261 | + $functionsCodes['@' . $functionName . '(%%)'] = '<?php echo ' . $functionName . '(\1); ?>'; |
|
262 | 262 | } |
263 | 263 | } |
264 | 264 | |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | '{{ %% }}' => '<?php echo (\1); ?>', |
299 | 299 | ]; |
300 | 300 | |
301 | - if ($this->config[ 'allowPhpConstants' ] === true) { |
|
301 | + if ($this->config['allowPhpConstants'] === true) { |
|
302 | 302 | $constantsVariables = get_defined_constants(true); |
303 | 303 | |
304 | - if ( ! empty($constantsVariables[ 'user' ])) { |
|
305 | - foreach ($constantsVariables[ 'user' ] as $constant => $value) { |
|
306 | - $variablesCodes[ '{{ ' . $constant . ' }}' ] = '<?php echo ' . $constant . '; ?>'; |
|
304 | + if ( ! empty($constantsVariables['user'])) { |
|
305 | + foreach ($constantsVariables['user'] as $constant => $value) { |
|
306 | + $variablesCodes['{{ ' . $constant . ' }}'] = '<?php echo ' . $constant . '; ?>'; |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | } |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | |
347 | 347 | private function collectSection($match) |
348 | 348 | { |
349 | - $section = str_replace(['\'', '(', ')'], '', trim($match[ 1 ])); |
|
349 | + $section = str_replace(['\'', '(', ')'], '', trim($match[1])); |
|
350 | 350 | $xSection = explode(',', $section); |
351 | 351 | $xSection = array_map('trim', $xSection); |
352 | 352 | |
353 | - $this->sections[ $xSection[ 0 ] ] = $this->replaceString($xSection[ 1 ]); |
|
353 | + $this->sections[$xSection[0]] = $this->replaceString($xSection[1]); |
|
354 | 354 | |
355 | 355 | return null; |
356 | 356 | } |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | |
360 | 360 | private function collectSectionWithShow($match) |
361 | 361 | { |
362 | - $offset = str_replace(['(\'', '\')'], '', trim($match[ 1 ])); |
|
363 | - $this->sections[ $offset ] = $this->replaceString($match[ 2 ]); |
|
362 | + $offset = str_replace(['(\'', '\')'], '', trim($match[1])); |
|
363 | + $this->sections[$offset] = $this->replaceString($match[2]); |
|
364 | 364 | |
365 | 365 | return '@yield(\'' . $offset . '\')'; |
366 | 366 | } |
@@ -369,10 +369,10 @@ discard block |
||
369 | 369 | |
370 | 370 | private function collectSectionWithEnd($match) |
371 | 371 | { |
372 | - $offset = str_replace(['(\'', '\')'], '', trim($match[ 1 ])); |
|
373 | - $content = trim($match[ 2 ]); |
|
372 | + $offset = str_replace(['(\'', '\')'], '', trim($match[1])); |
|
373 | + $content = trim($match[2]); |
|
374 | 374 | |
375 | - $this->sections[ $offset ] = $this->replaceString($content); |
|
375 | + $this->sections[$offset] = $this->replaceString($content); |
|
376 | 376 | |
377 | 377 | return null; |
378 | 378 | } |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | |
382 | 382 | private function collectSectionWithParent($match) |
383 | 383 | { |
384 | - $offset = str_replace(['(\'', '\')'], '', trim($match[ 1 ])); |
|
385 | - $content = $this->replaceString($match[ 2 ]); |
|
384 | + $offset = str_replace(['(\'', '\')'], '', trim($match[1])); |
|
385 | + $content = $this->replaceString($match[2]); |
|
386 | 386 | |
387 | - if (isset($this->sections[ $offset ])) { |
|
388 | - $this->sections[ $offset ] .= PHP_EOL . $content; |
|
387 | + if (isset($this->sections[$offset])) { |
|
388 | + $this->sections[$offset] .= PHP_EOL . $content; |
|
389 | 389 | } else { |
390 | - $this->sections[ $offset ] = $content; |
|
390 | + $this->sections[$offset] = $content; |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | return null; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public function parseString($string, array $vars = []) |
68 | 68 | { |
69 | - if ($this->config[ 'allowPhpGlobals' ] === false) { |
|
69 | + if ($this->config['allowPhpGlobals'] === false) { |
|
70 | 70 | $string = str_replace( |
71 | 71 | [ |
72 | 72 | '{{$GLOBALS}}', |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | |
164 | 164 | // php function codes |
165 | 165 | $functionsCodes = []; |
166 | - if ($this->config[ 'allowPhpFunctions' ] === false) { |
|
166 | + if ($this->config['allowPhpFunctions'] === false) { |
|
167 | 167 | $functionsCodes = [ |
168 | 168 | '{{%%(%%)}}' => '', |
169 | 169 | ]; |
170 | - } elseif (is_array($this->config[ 'allowPhpFunctions' ]) AND count( |
|
171 | - $this->config[ 'allowPhpFunctions' ] |
|
170 | + } elseif (is_array($this->config['allowPhpFunctions']) AND count( |
|
171 | + $this->config['allowPhpFunctions'] |
|
172 | 172 | ) > 0 |
173 | 173 | ) { |
174 | - foreach ($this->config[ 'allowPhpFunctions' ] as $function_name) { |
|
174 | + foreach ($this->config['allowPhpFunctions'] as $function_name) { |
|
175 | 175 | if (function_exists($function_name)) { |
176 | - $functionsCodes[ '{{' . $function_name . '(%%)}}' ] = '<?php echo ' . $function_name . '(\1); ?>'; |
|
176 | + $functionsCodes['{{' . $function_name . '(%%)}}'] = '<?php echo ' . $function_name . '(\1); ?>'; |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | } else { |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | '{{ --%%-- }}' => '', |
232 | 232 | ]; |
233 | 233 | |
234 | - if ($this->config[ 'allowPhpConstants' ] === true) { |
|
234 | + if ($this->config['allowPhpConstants'] === true) { |
|
235 | 235 | $constantsVariables = get_defined_constants(true); |
236 | 236 | |
237 | - if ( ! empty($constantsVariables[ 'user' ])) { |
|
238 | - foreach ($constantsVariables[ 'user' ] as $constant => $value) { |
|
237 | + if ( ! empty($constantsVariables['user'])) { |
|
238 | + foreach ($constantsVariables['user'] as $constant => $value) { |
|
239 | 239 | if (defined($constant)) { |
240 | - $variablesCodes[ '{{' . $constant . '}}' ] = '<?php echo ' . $constant . '; ?>'; |
|
240 | + $variablesCodes['{{' . $constant . '}}'] = '<?php echo ' . $constant . '; ?>'; |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | { |
86 | 86 | $this->string = htmlspecialchars_decode($string); |
87 | 87 | |
88 | - if ($this->config[ 'allowPhpScripts' ] === false) { |
|
88 | + if ($this->config['allowPhpScripts'] === false) { |
|
89 | 89 | $this->string = preg_replace( |
90 | 90 | '/<\\?.*(\\?>|$)/Us', |
91 | 91 | '', |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public function setEngine($engine) |
127 | 127 | { |
128 | 128 | if ($this->isValidEngine($engine)) { |
129 | - $this->engine =& $engine; |
|
129 | + $this->engine = & $engine; |
|
130 | 130 | |
131 | 131 | return true; |
132 | 132 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * @param $className |
17 | 17 | */ |
18 | 18 | spl_autoload_register( |
19 | - function ($className) { |
|
19 | + function($className) { |
|
20 | 20 | if (strpos($className, 'O2System\Parser\\') === false) { |
21 | 21 | return; |
22 | 22 | } |