aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Parsing/Lexer/Lexer.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/Parsing/Lexer/Lexer.php')
-rw-r--r--inc/Parsing/Lexer/Lexer.php28
1 files changed, 14 insertions, 14 deletions
diff --git a/inc/Parsing/Lexer/Lexer.php b/inc/Parsing/Lexer/Lexer.php
index 20040938e..168127138 100644
--- a/inc/Parsing/Lexer/Lexer.php
+++ b/inc/Parsing/Lexer/Lexer.php
@@ -1,4 +1,5 @@
<?php
+
/**
* Lexer adapted from Simple Test: http://sourceforge.net/projects/simpletest/
* For an intro to the Lexer see:
@@ -18,13 +19,13 @@ namespace dokuwiki\Parsing\Lexer;
class Lexer
{
/** @var ParallelRegex[] */
- protected $regexes;
+ protected $regexes = [];
/** @var \Doku_Handler */
protected $handler;
/** @var StateStack */
protected $modeStack;
/** @var array mode "rewrites" */
- protected $mode_handlers;
+ protected $mode_handlers = [];
/** @var bool case sensitive? */
protected $case;
@@ -38,10 +39,8 @@ class Lexer
public function __construct($handler, $start = "accept", $case = false)
{
$this->case = $case;
- $this->regexes = array();
$this->handler = $handler;
$this->modeStack = new StateStack($start);
- $this->mode_handlers = array();
}
/**
@@ -141,13 +140,13 @@ class Lexer
$length = $initialLength;
$pos = 0;
while (is_array($parsed = $this->reduce($raw))) {
- list($unmatched, $matched, $mode) = $parsed;
+ [$unmatched, $matched, $mode] = $parsed;
$currentLength = strlen($raw);
$matchPos = $initialLength - $currentLength - strlen($matched);
if (! $this->dispatchTokens($unmatched, $matched, $mode, $pos, $matchPos)) {
return false;
}
- if ($currentLength == $length) {
+ if ($currentLength === $length) {
return false;
}
$length = $currentLength;
@@ -265,8 +264,8 @@ class Lexer
// modes starting with plugin_ are all handled by the same
// handler but with an additional parameter
- if (substr($handler, 0, 7)=='plugin_') {
- list($handler,$plugin) = sexplode('_', $handler, 2, '');
+ if (substr($handler, 0, 7) == 'plugin_') {
+ [$handler, $plugin] = sexplode('_', $handler, 2, '');
return $this->handler->$handler($content, $is_match, $pos, $plugin);
}
@@ -291,8 +290,8 @@ class Lexer
return true;
}
if ($action = $this->regexes[$this->modeStack->getCurrent()]->split($raw, $split)) {
- list($unparsed, $match, $raw) = $split;
- return array($unparsed, $match, $action);
+ [$unparsed, $match, $raw] = $split;
+ return [$unparsed, $match, $action];
}
return true;
}
@@ -305,7 +304,7 @@ class Lexer
*/
public static function escape($str)
{
- $chars = array(
+ $chars = [
'/\\\\/',
'/\./',
'/\+/',
@@ -323,9 +322,9 @@ class Lexer
'/\>/',
'/\|/',
'/\:/'
- );
+ ];
- $escaped = array(
+ $escaped = [
'\\\\\\\\',
'\.',
'\+',
@@ -343,7 +342,8 @@ class Lexer
'\>',
'\|',
'\:'
- );
+ ];
+
return preg_replace($chars, $escaped, $str);
}
}