@@ -71,8 +71,8 @@ |
||
| 71 | 71 | if ($this->isSupported()) {
|
| 72 | 72 | $this->engine = \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( |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | $driverClassName = '\O2System\Parser\Drivers\\' . ucfirst($driverOffset) . 'Driver'; |
| 118 | 118 | |
| 119 | 119 | if (class_exists($driverClassName)) {
|
| 120 | - if (isset($config[ 'engine' ])) {
|
|
| 121 | - unset($config[ 'engine' ]); |
|
| 120 | + if (isset($config['engine'])) {
|
|
| 121 | + unset($config['engine']); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $this->register((new $driverClassName())->initialize($config), $driverOffset); |
@@ -145,13 +145,13 @@ discard block |
||
| 145 | 145 | $driverOffset = strtolower($driverOffset); |
| 146 | 146 | |
| 147 | 147 | if ($this->config->offsetExists($driverOffset)) {
|
| 148 | - $config = $this->config[ $driverOffset ]; |
|
| 148 | + $config = $this->config[$driverOffset]; |
|
| 149 | 149 | } else {
|
| 150 | 150 | $config = $this->config->getArrayCopy(); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if (isset($config[ 'engine' ])) {
|
|
| 154 | - unset($config[ 'engine' ]); |
|
| 153 | + if (isset($config['engine'])) {
|
|
| 154 | + unset($config['engine']); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | if ($driver->isInitialize()) {
|
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | continue; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - $engine =& $driverEngine->getEngine(); |
|
| 288 | + $engine = & $driverEngine->getEngine(); |
|
| 289 | 289 | |
| 290 | 290 | if ($engine instanceof ParserEngineInterface) {
|
| 291 | 291 | $engine->addFilePath($this->sourceFileDirectory); |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | $inString = 0; |
| 403 | 403 | foreach (token_get_all('<?php ' . $sourceCode) as $token) {
|
| 404 | 404 | if (is_array($token)) {
|
| 405 | - switch ($token[ 0 ]) {
|
|
| 405 | + switch ($token[0]) {
|
|
| 406 | 406 | case T_CURLY_OPEN: |
| 407 | 407 | case T_DOLLAR_OPEN_CURLY_BRACES: |
| 408 | 408 | case T_START_HEREDOC: |
@@ -460,10 +460,10 @@ discard block |
||
| 460 | 460 | $sourceCode = ob_get_clean(); |
| 461 | 461 | $sourceCode = strip_tags($sourceCode); |
| 462 | 462 | if (preg_match("'syntax error, (.+) in .+ on line (\d+)$'s", $sourceCode, $sourceCode)) {
|
| 463 | - $sourceCode[ 2 ] = (int)$sourceCode[ 2 ]; |
|
| 464 | - $sourceCode = $sourceCode[ 2 ] <= $braces |
|
| 465 | - ? [$sourceCode[ 1 ], $sourceCode[ 2 ]] |
|
| 466 | - : ['unexpected $end' . substr($sourceCode[ 1 ], 14), $braces]; |
|
| 463 | + $sourceCode[2] = (int)$sourceCode[2]; |
|
| 464 | + $sourceCode = $sourceCode[2] <= $braces |
|
| 465 | + ? [$sourceCode[1], $sourceCode[2]] |
|
| 466 | + : ['unexpected $end' . substr($sourceCode[1], 14), $braces]; |
|
| 467 | 467 | } else {
|
| 468 | 468 | $sourceCode = ['syntax error', 0]; |
| 469 | 469 | } |
@@ -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 | } |
@@ -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 ''; |