From 42ea7f447f39fbc2f79eaaec31f8c10ede59c5d0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 11:30:27 +0200 Subject: Many PHPDocs, some unused and dyn declared vars many PHPDocs some unused variables some dynamically declared variables declared --- inc/parser/handler.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'inc/parser/handler.php') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index a1040d12e..0e7b294e5 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -711,6 +711,9 @@ class Doku_Handler_CallWriter { var $Handler; + /** + * @param Doku_Handler $Handler + */ function Doku_Handler_CallWriter(& $Handler) { $this->Handler = & $Handler; } @@ -747,7 +750,7 @@ class Doku_Handler_Nest { /** * constructor * - * @param object $CallWriter the renderers current call writer + * @param Doku_Handler_CallWriter $CallWriter the renderers current call writer * @param string $close closing instruction name, this is required to properly terminate the * syntax mode if the document ends without a closing pattern */ -- cgit v1.2.3 From 10bcc8aaa0f8014e1c5e2d059ea674fc0063233d Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Mon, 1 Dec 2014 17:01:23 +0000 Subject: provide node/leaf state data in listitem_open instruction parameter --- inc/parser/handler.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'inc/parser/handler.php') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index a1040d12e..5e0aa6ff4 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -805,6 +805,8 @@ class Doku_Handler_List { var $listCalls = array(); var $listStack = array(); + const NODE = 1; + function Doku_Handler_List(& $CallWriter) { $this->CallWriter = & $CallWriter; } @@ -856,7 +858,8 @@ class Doku_Handler_List { $depth = $this->interpretSyntax($call[1][0], $listType); $this->initialDepth = $depth; - $this->listStack[] = array($listType, $depth); + // array(list type, current depth, index of current listitem_open) + $this->listStack[] = array($listType, $depth, 1); $this->listCalls[] = array('list'.$listType.'_open',array(),$call[2]); $this->listCalls[] = array('listitem_open',array(1),$call[2]); @@ -881,6 +884,7 @@ class Doku_Handler_List { function listOpen($call) { $depth = $this->interpretSyntax($call[1][0], $listType); $end = end($this->listStack); + $key = key($this->listStack); // Not allowed to be shallower than initialDepth if ( $depth < $this->initialDepth ) { @@ -897,6 +901,9 @@ class Doku_Handler_List { $this->listCalls[] = array('listitem_open',array($depth-1),$call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); + // new list item, update list stack's index into current listitem_open + $this->listStack[$key][2] = count($this->listCalls) - 2; + // Switched list type... } else { @@ -908,7 +915,7 @@ class Doku_Handler_List { $this->listCalls[] = array('listcontent_open',array(),$call[2]); array_pop($this->listStack); - $this->listStack[] = array($listType, $depth); + $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2); } //------------------------------------------------------------------------ @@ -920,7 +927,10 @@ class Doku_Handler_List { $this->listCalls[] = array('listitem_open', array($depth-1), $call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); - $this->listStack[] = array($listType, $depth); + // set the node/leaf state of this item's parent listitem_open to NODE + $this->listCalls[$this->listStack[$key][2]][1][1] = self::NODE; + + $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2); //------------------------------------------------------------------------ // Getting shallower ( $depth < $end[1] ) @@ -934,6 +944,7 @@ class Doku_Handler_List { while (1) { $end = end($this->listStack); + $key = key($this->listStack); if ( $end[1] <= $depth ) { @@ -946,6 +957,9 @@ class Doku_Handler_List { $this->listCalls[] = array('listitem_open',array($depth-1),$call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); + // new list item, update list stack's index into current listitem_open + $this->listStack[$key][2] = count($this->listCalls) - 2; + } else { // Switching list type... $this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]); @@ -954,7 +968,7 @@ class Doku_Handler_List { $this->listCalls[] = array('listcontent_open',array(),$call[2]); array_pop($this->listStack); - $this->listStack[] = array($listType, $depth); + $this->listStack[] = array($listType, $depth, count($this->listCalls) - 2); } break; -- cgit v1.2.3 From 51a883ed288fd1a0a93fc2723019a334d104b179 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 3 Dec 2014 00:08:35 +0100 Subject: phpdocs handler --- inc/parser/handler.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/parser/handler.php') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index a1040d12e..8efaa2cc1 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -71,6 +71,7 @@ class Doku_Handler { */ function plugin($match, $state, $pos, $pluginname){ $data = array($match); + /** @var DokuWiki_Syntax_Plugin $plugin */ $plugin = plugin_load('syntax',$pluginname); if($plugin != null){ $data = $plugin->handle($match, $state, $pos, $this); -- cgit v1.2.3 From 38c6f603e006f27fd6194d1d2c14d3087d0e0cc9 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Wed, 7 Jan 2015 21:53:22 -0800 Subject: Optionally render RSS unsorted. By default, SimplePie sorts RSS entries by the the date on each entry. If some cases, mostly where RSS is used as a input format for another service, rendering the order as-is is better than having it sorted. This patch adds a new parameter for the rss keyword, 'nosort', which can be used to disable SimplePie's sorting. This makes it possible to correctly display RSS feeds from "Remember The Milk", which have a complex order from the system. Signed-off-by: Robin H. Johnson --- inc/parser/handler.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/parser/handler.php') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index d96a01a60..731c19828 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -526,6 +526,7 @@ class Doku_Handler { $p['author'] = (preg_match('/\b(by|author)/',$params)); $p['date'] = (preg_match('/\b(date)/',$params)); $p['details'] = (preg_match('/\b(desc|detail)/',$params)); + $p['nosort'] = (preg_match('/\b(nosort)\b/',$params)); if (preg_match('/\b(\d+)([dhm])\b/',$params,$match)) { $period = array('d' => 86400, 'h' => 3600, 'm' => 60); -- cgit v1.2.3 From 276820f70d7e96ee375735c1a15bdc0a8331a5a7 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Sat, 10 Jan 2015 14:47:51 +0000 Subject: Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- inc/parser/handler.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'inc/parser/handler.php') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 731c19828..b8e2de82a 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -21,6 +21,9 @@ class Doku_Handler { $this->CallWriter = new Doku_Handler_CallWriter($this); } + /** + * @param string $handler + */ function _addCall($handler, $args, $pos) { $call = array($handler,$args, $pos); $this->CallWriter->writeCall($call); @@ -133,6 +136,9 @@ class Doku_Handler { return true; } + /** + * @param string $name + */ function _nestingTag($match, $state, $pos, $name) { switch ( $state ) { case DOKU_LEXER_ENTER: -- cgit v1.2.3 From 26e22ab837dcabe137a0912fcd2f96d0c35f48c8 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 15 May 2015 19:03:34 +0200 Subject: Changes for PHP 7 Compatibility - replace PHP4 style class constructor function names (based on class name) with php 5 __construct() Also remove some '&' reference operators used with objects And add some object type hints --- inc/parser/handler.php | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'inc/parser/handler.php') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index b8e2de82a..815ac39c5 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -17,7 +17,7 @@ class Doku_Handler { var $rewriteBlocks = true; - function Doku_Handler() { + function __construct() { $this->CallWriter = new Doku_Handler_CallWriter($this); } @@ -295,7 +295,7 @@ class Doku_Handler { switch ( $state ) { case DOKU_LEXER_ENTER: $ReWriter = new Doku_Handler_Preformatted($this->CallWriter); - $this->CallWriter = & $ReWriter; + $this->CallWriter = $ReWriter; $this->_addCall('preformatted_start',array(), $pos); break; case DOKU_LEXER_EXIT: @@ -715,15 +715,21 @@ function Doku_Handler_Parse_Media($match) { } //------------------------------------------------------------------------ -class Doku_Handler_CallWriter { +interface Doku_Handler_CallWriter_Interface { + public function writeCall($call); + public function writeCalls($calls); + public function finalise(); +} + +class Doku_Handler_CallWriter implements Doku_Handler_CallWriter_Interface { var $Handler; /** * @param Doku_Handler $Handler */ - function Doku_Handler_CallWriter(& $Handler) { - $this->Handler = & $Handler; + function __construct(Doku_Handler $Handler) { + $this->Handler = $Handler; } function writeCall($call) { @@ -748,7 +754,7 @@ class Doku_Handler_CallWriter { * * @author Chris Smith */ -class Doku_Handler_Nest { +class Doku_Handler_Nest implements Doku_Handler_CallWriter_Interface { var $CallWriter; var $calls = array(); @@ -762,8 +768,8 @@ class Doku_Handler_Nest { * @param string $close closing instruction name, this is required to properly terminate the * syntax mode if the document ends without a closing pattern */ - function Doku_Handler_Nest(& $CallWriter, $close="nest_close") { - $this->CallWriter = & $CallWriter; + function __construct(Doku_Handler_CallWriter_Interface $CallWriter, $close="nest_close") { + $this->CallWriter = $CallWriter; $this->closingInstruction = $close; } @@ -808,7 +814,7 @@ class Doku_Handler_Nest { } } -class Doku_Handler_List { +class Doku_Handler_List implements Doku_Handler_CallWriter_Interface { var $CallWriter; @@ -818,8 +824,8 @@ class Doku_Handler_List { const NODE = 1; - function Doku_Handler_List(& $CallWriter) { - $this->CallWriter = & $CallWriter; + function __construct(Doku_Handler_CallWriter_Interface $CallWriter) { + $this->CallWriter = $CallWriter; } function writeCall($call) { @@ -1018,7 +1024,7 @@ class Doku_Handler_List { } //------------------------------------------------------------------------ -class Doku_Handler_Preformatted { +class Doku_Handler_Preformatted implements Doku_Handler_CallWriter_Interface { var $CallWriter; @@ -1028,8 +1034,8 @@ class Doku_Handler_Preformatted { - function Doku_Handler_Preformatted(& $CallWriter) { - $this->CallWriter = & $CallWriter; + function __construct(Doku_Handler_CallWriter_Interface $CallWriter) { + $this->CallWriter = $CallWriter; } function writeCall($call) { @@ -1078,7 +1084,7 @@ class Doku_Handler_Preformatted { } //------------------------------------------------------------------------ -class Doku_Handler_Quote { +class Doku_Handler_Quote implements Doku_Handler_CallWriter_Interface { var $CallWriter; @@ -1086,8 +1092,8 @@ class Doku_Handler_Quote { var $quoteCalls = array(); - function Doku_Handler_Quote(& $CallWriter) { - $this->CallWriter = & $CallWriter; + function __construct(Doku_Handler_CallWriter_Interface $CallWriter) { + $this->CallWriter = $CallWriter; } function writeCall($call) { @@ -1170,7 +1176,7 @@ class Doku_Handler_Quote { } //------------------------------------------------------------------------ -class Doku_Handler_Table { +class Doku_Handler_Table implements Doku_Handler_CallWriter_Interface { var $CallWriter; @@ -1185,8 +1191,8 @@ class Doku_Handler_Table { var $currentRow = array('tableheader' => 0, 'tablecell' => 0); var $countTableHeadRows = 0; - function Doku_Handler_Table(& $CallWriter) { - $this->CallWriter = & $CallWriter; + function __construct(Doku_Handler_CallWriter_Interface $CallWriter) { + $this->CallWriter = $CallWriter; } function writeCall($call) { @@ -1551,7 +1557,7 @@ class Doku_Handler_Block { * * @author Andreas Gohr */ - function Doku_Handler_Block(){ + function __construct(){ global $DOKU_PLUGINS; //check if syntax plugins were loaded if(empty($DOKU_PLUGINS['syntax'])) return; -- cgit v1.2.3