Skip to content

Commit f1cd25d

Browse files
committed
dont use static variables
1 parent fda24ee commit f1cd25d

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

syntax/caption.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class syntax_plugin_latexcaption_caption extends \dokuwiki\Extension\SyntaxPlugi
1515
* Static variables set to keep track when scope is left.
1616
*/
1717
private static $_types = array('figure', 'table','codeblock','fileblock');
18-
private static $_type = '';
19-
private static $_incaption = false;
20-
private static $_label = '';
21-
private static $_opts = array();
22-
private static $_parOpts = array();
23-
private static $_nested = false;
18+
private $_type = '';
19+
private $_incaption = false;
20+
private $_label = '';
21+
private $_opts = array();
22+
private $_parOpts = array();
23+
private $_nested = false;
2424

2525
/** @var $helper helper_plugin_latexcaption */
2626
var $helper = null;
@@ -91,14 +91,14 @@ public function handle($match, $state, $pos, Doku_Handler $handler){
9191
$opts = (!empty($opts) ? explode(' ', $opts) : ['noalign',]);
9292

9393
// Set dynamic class counter variable
94-
$type_counter_def = '$_'.$type.'_count';
94+
$type_counter_def = '_'.$type.'_count';
9595

9696
// Increment the counter of relevant type
9797
// Store the type in class for caption match to determine what html tag to use
9898
// This is ok since we will never have nested figures and more than one caption
99-
$this::$_type = $type;
100-
$this::$_label = $label;
101-
$this::$_opts = $opts;
99+
$this->_type = $type;
100+
$this->_label = $label;
101+
$this->_opts = $opts;
102102
$this->{$type_counter_def} = (!isset($this->{$type_counter_def}) ? 1 : $this->{$type_counter_def}+1);
103103

104104
// save params to class variables (cached for use in render)
@@ -110,16 +110,16 @@ public function handle($match, $state, $pos, Doku_Handler $handler){
110110
// Check if we are counting a subtype to store parent in array for references
111111
if ($this->isSubType($type)) {
112112
$partype = $this->getParType($type);
113-
$parcount = $this->{'$_'.$partype.'_count'};
113+
$parcount = $this->{'_'.$partype.'_count'};
114114
}
115115
$caption_count[$label] = array($type, $type_counter, $parcount);
116116
}
117117

118118
//Save parent options for use later
119119
if (!$this->isSubType($type)){
120-
$this::$_parOpts = $opts;
120+
$this->_parOpts = $opts;
121121
} else {
122-
$this::$_nested = true;
122+
$this->_nested = true;
123123
}
124124

125125
// Set the params
@@ -133,15 +133,15 @@ public function handle($match, $state, $pos, Doku_Handler $handler){
133133
if ($state == DOKU_LEXER_MATCHED){
134134
// Case of caption.
135135
// Toggle the incaption flag
136-
$this::$_incaption = !$this::$_incaption;
137-
$type = $this::$_type;
138-
$params['label'] = $this::$_label;
136+
$this->_incaption = !$this->_incaption;
137+
$type = $this->_type;
138+
$params['label'] = $this->_label;
139139
$params['xhtml']['captagtype'] = (in_array($type, ['figure', 'subfigure']) ? 'figcaption' : 'div');
140-
$params['incaption'] = $this::$_incaption;
141-
$params['type_counter'] = $this->{'$_'.$type.'_count'};
140+
$params['incaption'] = $this->_incaption;
141+
$params['type_counter'] = $this->{'_'.$type.'_count'};
142142
$params['type'] = $type;
143143
// Decide what caption options to send to renderer
144-
$params['opts'] = ($this::$_nested ? $this::$_opts : $this::$_parOpts);
144+
$params['opts'] = ($this->_nested ? $this->_opts : $this->_parOpts);
145145

146146

147147
return array($state, $match, $pos, $params);
@@ -150,16 +150,16 @@ public function handle($match, $state, $pos, Doku_Handler $handler){
150150
return array($state, $match, $pos, $params);
151151
}
152152
if ($state == DOKU_LEXER_EXIT){
153-
$type = $this::$_type;
153+
$type = $this->_type;
154154

155155
if (substr($type, 0, 3) == 'sub') {
156156
// Change environment back to non sub type
157-
$this::$_type = substr($type, 3);
158-
$this::$_nested = false;
157+
$this->_type = substr($type, 3);
158+
$this->_nested = false;
159159
}
160160
else {
161161
// reset subtype counter
162-
$this->{'$_sub'.$type.'_count'} = 0;
162+
$this->{'_sub'.$type.'_count'} = 0;
163163
}
164164
$params['type'] = $type;
165165
$params['xhtml']['tagtype'] = (in_array($type, ['figure', 'subfigure']) ? 'figure' : 'div');
@@ -181,7 +181,7 @@ public function handle($match, $state, $pos, Doku_Handler $handler){
181181
}
182182

183183
// Update the counter. offset by 1 since counter is incremented on caption enter
184-
$this->{'$_'.$type.'_count'} = $num-1;
184+
$this->{'_'.$type.'_count'} = $num-1;
185185

186186
return true;
187187
}

0 commit comments

Comments
 (0)