@@ -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 | } |
@@ -102,16 +102,16 @@ discard block |
||
102 | 102 | $this->config = $config; |
103 | 103 | |
104 | 104 | if ($this->config->offsetExists('template')) { |
105 | - if(is_array($this->config->template)) { |
|
106 | - foreach($this->config->template as $engine) { |
|
105 | + if (is_array($this->config->template)) { |
|
106 | + foreach ($this->config->template as $engine) { |
|
107 | 107 | $this->template->load($engine); |
108 | 108 | } |
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | 112 | if ($this->config->offsetExists('string')) { |
113 | - if(is_array($this->config->string)) { |
|
114 | - foreach($this->config->string as $engine) { |
|
113 | + if (is_array($this->config->string)) { |
|
114 | + foreach ($this->config->string as $engine) { |
|
115 | 115 | $this->string->load($engine); |
116 | 116 | } |
117 | 117 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public function parsePhp(array $vars = []) |
258 | 258 | { |
259 | - if(count($vars)) { |
|
259 | + if (count($vars)) { |
|
260 | 260 | $this->loadVars($vars); |
261 | 261 | } |
262 | 262 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | $inString = 0; |
333 | 333 | foreach (token_get_all('<?php ' . $sourceCode) as $token) { |
334 | 334 | if (is_array($token)) { |
335 | - switch ($token[ 0 ]) { |
|
335 | + switch ($token[0]) { |
|
336 | 336 | case T_CURLY_OPEN: |
337 | 337 | case T_DOLLAR_OPEN_CURLY_BRACES: |
338 | 338 | case T_START_HEREDOC: |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | $sourceCode = ob_get_clean(); |
391 | 391 | $sourceCode = strip_tags($sourceCode); |
392 | 392 | if (preg_match("'syntax error, (.+) in .+ on line (\d+)$'s", $sourceCode, $sourceCode)) { |
393 | - $sourceCode[ 2 ] = (int)$sourceCode[ 2 ]; |
|
394 | - $sourceCode = $sourceCode[ 2 ] <= $braces |
|
395 | - ? [$sourceCode[ 1 ], $sourceCode[ 2 ]] |
|
396 | - : ['unexpected $end' . substr($sourceCode[ 1 ], 14), $braces]; |
|
393 | + $sourceCode[2] = (int)$sourceCode[2]; |
|
394 | + $sourceCode = $sourceCode[2] <= $braces |
|
395 | + ? [$sourceCode[1], $sourceCode[2]] |
|
396 | + : ['unexpected $end' . substr($sourceCode[1], 14), $braces]; |
|
397 | 397 | } else { |
398 | 398 | $sourceCode = ['syntax error', 0]; |
399 | 399 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @return static |
36 | 36 | * @throws \O2System\Spl\Exceptions\RuntimeException |
37 | 37 | */ |
38 | - public function initialize(array $config =[]) |
|
38 | + public function initialize(array $config = []) |
|
39 | 39 | { |
40 | 40 | if (empty($this->engine)) { |
41 | 41 | if ($this->isSupported()) { |
@@ -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 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function parseString($string, array $vars = []) |
97 | 97 | { |
98 | - $this->vars =& $vars; |
|
98 | + $this->vars = & $vars; |
|
99 | 99 | |
100 | 100 | // Collect sections with no closing |
101 | 101 | $string = preg_replace_callback('/@section((.*),(.*))/', [&$this, 'collectSection'], $string); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | private function replaceString($string) |
154 | 154 | { |
155 | - if ($this->config[ 'allowPhpGlobals' ] === false) { |
|
155 | + if ($this->config['allowPhpGlobals'] === false) { |
|
156 | 156 | $string = str_replace( |
157 | 157 | [ |
158 | 158 | '{{$GLOBALS}}', |
@@ -273,14 +273,14 @@ discard block |
||
273 | 273 | '@choice( %%,%% )' => '@choice not supported', |
274 | 274 | ]; |
275 | 275 | |
276 | - if ($this->config[ 'allowPhpFunctions' ] === false) { |
|
277 | - $functionsCodes[ '@%%(%%)' ] = ''; |
|
278 | - } elseif (is_array($this->config[ 'allowPhpFunctions' ]) AND count( |
|
279 | - $this->config[ 'allowPhpFunctions' ] |
|
276 | + if ($this->config['allowPhpFunctions'] === false) { |
|
277 | + $functionsCodes['@%%(%%)'] = ''; |
|
278 | + } elseif (is_array($this->config['allowPhpFunctions']) AND count( |
|
279 | + $this->config['allowPhpFunctions'] |
|
280 | 280 | ) > 0 |
281 | 281 | ) { |
282 | - foreach ($this->config[ 'allowPhpFunctions' ] as $functionName) { |
|
283 | - $functionsCodes[ '@' . $functionName . '(%%)' ] = '<?php echo ' . $functionName . '(\1); ?>'; |
|
282 | + foreach ($this->config['allowPhpFunctions'] as $functionName) { |
|
283 | + $functionsCodes['@' . $functionName . '(%%)'] = '<?php echo ' . $functionName . '(\1); ?>'; |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | |
@@ -320,12 +320,12 @@ discard block |
||
320 | 320 | '{{ %% }}' => '<?php echo (\1); ?>', |
321 | 321 | ]; |
322 | 322 | |
323 | - if ($this->config[ 'allowPhpConstants' ] === true) { |
|
323 | + if ($this->config['allowPhpConstants'] === true) { |
|
324 | 324 | $constantsVariables = get_defined_constants(true); |
325 | 325 | |
326 | - if ( ! empty($constantsVariables[ 'user' ])) { |
|
327 | - foreach ($constantsVariables[ 'user' ] as $constant => $value) { |
|
328 | - $variablesCodes[ '{{ ' . $constant . ' }}' ] = '<?php echo ' . $constant . '; ?>'; |
|
326 | + if ( ! empty($constantsVariables['user'])) { |
|
327 | + foreach ($constantsVariables['user'] as $constant => $value) { |
|
328 | + $variablesCodes['{{ ' . $constant . ' }}'] = '<?php echo ' . $constant . '; ?>'; |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | } |
@@ -375,11 +375,11 @@ discard block |
||
375 | 375 | */ |
376 | 376 | private function collectSection($match) |
377 | 377 | { |
378 | - $section = str_replace(['\'', '(', ')'], '', trim($match[ 1 ])); |
|
378 | + $section = str_replace(['\'', '(', ')'], '', trim($match[1])); |
|
379 | 379 | $xSection = explode(',', $section); |
380 | 380 | $xSection = array_map('trim', $xSection); |
381 | 381 | |
382 | - $this->sections[ $xSection[ 0 ] ] = $this->replaceString($xSection[ 1 ]); |
|
382 | + $this->sections[$xSection[0]] = $this->replaceString($xSection[1]); |
|
383 | 383 | |
384 | 384 | return ''; |
385 | 385 | } |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | */ |
396 | 396 | private function collectSectionWithShow($match) |
397 | 397 | { |
398 | - $offset = str_replace(['(\'', '\')'], '', trim($match[ 1 ])); |
|
399 | - $this->sections[ $offset ] = $this->replaceString($match[ 2 ]); |
|
398 | + $offset = str_replace(['(\'', '\')'], '', trim($match[1])); |
|
399 | + $this->sections[$offset] = $this->replaceString($match[2]); |
|
400 | 400 | |
401 | 401 | return '@yield(\'' . $offset . '\')'; |
402 | 402 | } |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | */ |
413 | 413 | private function collectSectionWithEnd($match) |
414 | 414 | { |
415 | - $offset = str_replace(['(\'', '\')'], '', trim($match[ 1 ])); |
|
416 | - $content = trim($match[ 2 ]); |
|
415 | + $offset = str_replace(['(\'', '\')'], '', trim($match[1])); |
|
416 | + $content = trim($match[2]); |
|
417 | 417 | |
418 | - $this->sections[ $offset ] = $this->replaceString($content); |
|
418 | + $this->sections[$offset] = $this->replaceString($content); |
|
419 | 419 | |
420 | 420 | return ''; |
421 | 421 | } |
@@ -431,13 +431,13 @@ discard block |
||
431 | 431 | */ |
432 | 432 | private function collectSectionWithParent($match) |
433 | 433 | { |
434 | - $offset = str_replace(['(\'', '\')'], '', trim($match[ 1 ])); |
|
435 | - $content = $this->replaceString($match[ 2 ]); |
|
434 | + $offset = str_replace(['(\'', '\')'], '', trim($match[1])); |
|
435 | + $content = $this->replaceString($match[2]); |
|
436 | 436 | |
437 | - if (isset($this->sections[ $offset ])) { |
|
438 | - $this->sections[ $offset ] .= PHP_EOL . $content; |
|
437 | + if (isset($this->sections[$offset])) { |
|
438 | + $this->sections[$offset] .= PHP_EOL . $content; |
|
439 | 439 | } else { |
440 | - $this->sections[ $offset ] = $content; |
|
440 | + $this->sections[$offset] = $content; |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | return ''; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function parseString($string, array $vars = []) |
75 | 75 | { |
76 | - if ($this->config[ 'allowPhpGlobals' ] === false) { |
|
76 | + if ($this->config['allowPhpGlobals'] === false) { |
|
77 | 77 | $string = str_replace( |
78 | 78 | [ |
79 | 79 | '{{$GLOBALS}}', |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | |
171 | 171 | // php function codes |
172 | 172 | $functionsCodes = []; |
173 | - if ($this->config[ 'allowPhpFunctions' ] === false) { |
|
173 | + if ($this->config['allowPhpFunctions'] === false) { |
|
174 | 174 | $functionsCodes = [ |
175 | 175 | '{{%%(%%)}}' => '', |
176 | 176 | ]; |
177 | - } elseif (is_array($this->config[ 'allowPhpFunctions' ]) AND count( |
|
178 | - $this->config[ 'allowPhpFunctions' ] |
|
177 | + } elseif (is_array($this->config['allowPhpFunctions']) AND count( |
|
178 | + $this->config['allowPhpFunctions'] |
|
179 | 179 | ) > 0 |
180 | 180 | ) { |
181 | - foreach ($this->config[ 'allowPhpFunctions' ] as $function_name) { |
|
181 | + foreach ($this->config['allowPhpFunctions'] as $function_name) { |
|
182 | 182 | if (function_exists($function_name)) { |
183 | - $functionsCodes[ '{{' . $function_name . '(%%)}}' ] = '<?php echo ' . $function_name . '(\1); ?>'; |
|
183 | + $functionsCodes['{{' . $function_name . '(%%)}}'] = '<?php echo ' . $function_name . '(\1); ?>'; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | } else { |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | '{{ --%%-- }}' => '', |
239 | 239 | ]; |
240 | 240 | |
241 | - if ($this->config[ 'allowPhpConstants' ] === true) { |
|
241 | + if ($this->config['allowPhpConstants'] === true) { |
|
242 | 242 | $constantsVariables = get_defined_constants(true); |
243 | 243 | |
244 | - if ( ! empty($constantsVariables[ 'user' ])) { |
|
245 | - foreach ($constantsVariables[ 'user' ] as $constant => $value) { |
|
244 | + if ( ! empty($constantsVariables['user'])) { |
|
245 | + foreach ($constantsVariables['user'] as $constant => $value) { |
|
246 | 246 | if (defined($constant)) { |
247 | - $variablesCodes[ '{{' . $constant . '}}' ] = '<?php echo ' . $constant . '; ?>'; |
|
247 | + $variablesCodes['{{' . $constant . '}}'] = '<?php echo ' . $constant . '; ?>'; |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | } |
@@ -97,14 +97,14 @@ |
||
97 | 97 | { |
98 | 98 | $output = $string; |
99 | 99 | |
100 | - if(is_file($string)) { |
|
100 | + if (is_file($string)) { |
|
101 | 101 | $output = file_get_contents($string); |
102 | 102 | } |
103 | 103 | |
104 | - if($this->count()) { |
|
105 | - foreach($this->registry as $adapter) { |
|
106 | - if($adapter instanceof Abstracts\AbstractAdapter) { |
|
107 | - if($adapter->isSupported()) { |
|
104 | + if ($this->count()) { |
|
105 | + foreach ($this->registry as $adapter) { |
|
106 | + if ($adapter instanceof Abstracts\AbstractAdapter) { |
|
107 | + if ($adapter->isSupported()) { |
|
108 | 108 | $adapter->initialize(); |
109 | 109 | $adapter->loadString($output); |
110 | 110 | $output = $adapter->parse($vars); |
@@ -71,8 +71,8 @@ |
||
71 | 71 | if ($this->isSupported()) { |
72 | 72 | $this->engine = new \cebe\markdown\Markdown(); |
73 | 73 | |
74 | - if (isset($config[ 'flavour' ])) { |
|
75 | - $this->setFlavour($config[ 'flavour' ]); |
|
74 | + if (isset($config['flavour'])) { |
|
75 | + $this->setFlavour($config['flavour']); |
|
76 | 76 | } |
77 | 77 | } else { |
78 | 78 | throw new RuntimeException( |
@@ -90,7 +90,7 @@ |
||
90 | 90 | public function setEngine($engine) |
91 | 91 | { |
92 | 92 | if ($this->isValidEngine($engine)) { |
93 | - $this->engine =& $engine; |
|
93 | + $this->engine = & $engine; |
|
94 | 94 | |
95 | 95 | return true; |
96 | 96 | } |