aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Parsing/Parser.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/Parsing/Parser.php')
-rw-r--r--inc/Parsing/Parser.php41
1 files changed, 22 insertions, 19 deletions
diff --git a/inc/Parsing/Parser.php b/inc/Parsing/Parser.php
index 63f014161..018f45eaa 100644
--- a/inc/Parsing/Parser.php
+++ b/inc/Parsing/Parser.php
@@ -2,6 +2,7 @@
namespace dokuwiki\Parsing;
+use dokuwiki\Debug\DebugHelper;
use Doku_Handler;
use dokuwiki\Parsing\Lexer\Lexer;
use dokuwiki\Parsing\ParserMode\Base;
@@ -11,8 +12,8 @@ use dokuwiki\Parsing\ParserMode\ModeInterface;
* Sets up the Lexer with modes and points it to the Handler
* For an intro to the Lexer see: wiki:parser
*/
-class Parser {
-
+class Parser
+{
/** @var Doku_Handler */
protected $handler;
@@ -20,7 +21,7 @@ class Parser {
protected $lexer;
/** @var ModeInterface[] $modes */
- protected $modes = array();
+ protected $modes = [];
/** @var bool mode connections may only be set up once */
protected $connected = false;
@@ -30,7 +31,8 @@ class Parser {
*
* @param Doku_Handler $handler
*/
- public function __construct(Doku_Handler $handler) {
+ public function __construct(Doku_Handler $handler)
+ {
$this->handler = $handler;
}
@@ -39,9 +41,10 @@ class Parser {
*
* @param Base $BaseMode
*/
- protected function addBaseMode($BaseMode) {
+ protected function addBaseMode($BaseMode)
+ {
$this->modes['base'] = $BaseMode;
- if(!$this->lexer) {
+ if (!$this->lexer) {
$this->lexer = new Lexer($this->handler, 'base', true);
}
$this->modes['base']->Lexer = $this->lexer;
@@ -56,8 +59,9 @@ class Parser {
* @param string $name
* @param ModeInterface $Mode
*/
- public function addMode($name, ModeInterface $Mode) {
- if(!isset($this->modes['base'])) {
+ public function addMode($name, ModeInterface $Mode)
+ {
+ if (!isset($this->modes['base'])) {
$this->addBaseMode(new Base());
}
$Mode->Lexer = $this->lexer; // FIXME should be done by setter
@@ -69,25 +73,24 @@ class Parser {
*
* This is the last step before actually parsing.
*/
- protected function connectModes() {
+ protected function connectModes()
+ {
- if($this->connected) {
+ if ($this->connected) {
return;
}
- foreach(array_keys($this->modes) as $mode) {
+ foreach (array_keys($this->modes) as $mode) {
// Base isn't connected to anything
- if($mode == 'base') {
+ if ($mode == 'base') {
continue;
}
$this->modes[$mode]->preConnect();
- foreach(array_keys($this->modes) as $cm) {
-
- if($this->modes[$cm]->accepts($mode)) {
+ foreach (array_keys($this->modes) as $cm) {
+ if ($this->modes[$cm]->accepts($mode)) {
$this->modes[$mode]->connectTo($cm);
}
-
}
$this->modes[$mode]->postConnect();
@@ -102,7 +105,8 @@ class Parser {
* @param string $doc the wiki syntax text
* @return array instructions
*/
- public function parse($doc) {
+ public function parse($doc)
+ {
$this->connectModes();
// Normalize CRs and pad doc
$doc = "\n" . str_replace("\r\n", "\n", $doc) . "\n";
@@ -111,7 +115,7 @@ class Parser {
if (!method_exists($this->handler, 'finalize')) {
/** @deprecated 2019-10 we have a legacy handler from a plugin, assume legacy _finalize exists */
- \dokuwiki\Debug\DebugHelper::dbgCustomDeprecationEvent(
+ DebugHelper::dbgCustomDeprecationEvent(
'finalize()',
get_class($this->handler) . '::_finalize()',
__METHOD__,
@@ -124,5 +128,4 @@ class Parser {
}
return $this->handler->calls;
}
-
}