@@ -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 {
|
@@ -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 | } |
@@ -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 ''; |
@@ -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( |