Completed
Push — scrutinizer ( c2ef4a...84e9d0 )
by Fabio
22:07
created
framework/3rdParty/TextHighlighter/Text/Highlighter/Generator.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -262,6 +262,7 @@  discard block
 block discarded – undo
262 262
     * Sets the input xml file to be parsed
263 263
     *
264 264
     * @param    string      Filename (full path)
265
+    * @param string $file
265 266
     * @return   boolean
266 267
     * @access   public
267 268
     */
@@ -768,7 +769,6 @@  discard block
 block discarded – undo
768 769
     * Add an error message
769 770
     *
770 771
     * @param integer $code Error code
771
-    * @param mixed   $message Error message or array with error message parameters
772 772
     * @param integer $lineNo Source code line number
773 773
     * @access private
774 774
     */
Please login to merge, or discard this patch.
Indentation   +1092 added lines, -1092 removed lines patch added patch discarded remove patch
@@ -67,949 +67,949 @@  discard block
 block discarded – undo
67 67
 
68 68
 class Text_Highlighter_Generator extends  XML_Parser
69 69
 {
70
-    // {{{ properties
71
-    /**
72
-    * Whether to do case folding.
73
-    * We have to declare it here, because XML_Parser
74
-    * sets case folding in constructor
75
-    *
76
-    * @var  boolean
77
-    */
78
-    var $folding = false;
79
-
80
-    /**
81
-    * Holds name of file with highlighting rules
82
-    *
83
-    * @var string
84
-    * @access private
85
-    */
86
-    var $_syntaxFile;
87
-
88
-    /**
89
-    * Current element being processed
90
-    *
91
-    * @var array
92
-    * @access private
93
-    */
94
-    var $_element;
95
-
96
-    /**
97
-    * List of regions
98
-    *
99
-    * @var array
100
-    * @access private
101
-    */
102
-    var $_regions = array();
103
-
104
-    /**
105
-    * List of blocks
106
-    *
107
-    * @var array
108
-    * @access private
109
-    */
110
-    var $_blocks = array();
111
-
112
-    /**
113
-    * List of keyword groups
114
-    *
115
-    * @var array
116
-    * @access private
117
-    */
118
-    var $_keywords = array();
119
-
120
-    /**
121
-    * List of authors
122
-    *
123
-    * @var array
124
-    * @access private
125
-    */
126
-    var $_authors = array();
127
-
128
-    /**
129
-    * Name of language
130
-    *
131
-    * @var string
132
-    * @access public
133
-    */
134
-    var $language = '';
135
-
136
-    /**
137
-    * Generated code
138
-    *
139
-    * @var string
140
-    * @access private
141
-    */
142
-    var $_code = '';
143
-
144
-    /**
145
-    * Default class
146
-    *
147
-    * @var string
148
-    * @access private
149
-    */
150
-    var $_defClass = 'default';
151
-
152
-    /**
153
-    * Comment
154
-    *
155
-    * @var string
156
-    * @access private
157
-    */
158
-    var $_comment = '';
159
-
160
-    /**
161
-    * Flag for comment processing
162
-    *
163
-    * @var boolean
164
-    * @access private
165
-    */
166
-    var $_inComment = false;
167
-
168
-    /**
169
-    * Sorting order of current block/region
170
-    *
171
-    * @var integer
172
-    * @access private
173
-    */
174
-    var $_blockOrder = 0;
175
-
176
-    /**
177
-    * Generation errors
178
-    *
179
-    * @var array
180
-    * @access private
181
-    */
182
-    var $_errors;
183
-
184
-    // }}}
185
-    // {{{ constructor
186
-
187
-    /**
188
-    * Constructor
189
-    *
190
-    * @param string $syntaxFile Name of XML file
191
-    * with syntax highlighting rules
192
-    *
193
-    * @access public
194
-    */
195
-
196
-    function __construct($syntaxFile = '')
197
-    {
198
-        XML_Parser::XML_Parser(null, 'func');
199
-        $this->_errors = array();
200
-        $this->_declareErrorMessages();
201
-        if ($syntaxFile) {
202
-            $this->setInputFile($syntaxFile);
203
-        }
204
-    }
205
-
206
-    // }}}
207
-    // {{{ _formatError
208
-
209
-    /**
210
-    * Format error message
211
-    *
212
-    * @param int $code error code
213
-    * @param string $params parameters
214
-    * @param string $fileName file name
215
-    * @param int $lineNo line number
216
-    * @return  array
217
-    * @access  public
218
-    */
219
-    function _formatError($code, $params, $fileName, $lineNo)
220
-    {
221
-        $template = $this->_templates[$code];
222
-        $ret = call_user_func_array('sprintf', array_merge(array($template), $params));
223
-        if ($fileName) {
224
-            $ret = '[' . $fileName . '] ' . $ret;
225
-        }
226
-        if ($lineNo) {
227
-            $ret .= ' (line ' . $lineNo . ')';
228
-        }
229
-        return $ret;
230
-    }
231
-
232
-    // }}}
233
-    // {{{ declareErrorMessages
234
-
235
-    /**
236
-    * Set up error message templates
237
-    *
238
-    * @access  private
239
-    */
240
-    function _declareErrorMessages()
241
-    {
242
-        $this->_templates = array (
243
-        TEXT_HIGHLIGHTER_EMPTY_RE => 'Empty regular expression',
244
-        TEXT_HIGHLIGHTER_INVALID_RE => 'Invalid regular expression : %s',
245
-        TEXT_HIGHLIGHTER_EMPTY_OR_MISSING => 'Empty or missing %s',
246
-        TEXT_HIGHLIGHTER_EMPTY  => 'Empty %s',
247
-        TEXT_HIGHLIGHTER_REGION_REGION => 'Region %s refers undefined region %s',
248
-        TEXT_HIGHLIGHTER_REGION_BLOCK => 'Region %s refers undefined block %s',
249
-        TEXT_HIGHLIGHTER_BLOCK_REGION => 'Block %s refers undefined region %s',
250
-        TEXT_HIGHLIGHTER_KEYWORD_BLOCK => 'Keyword group %s refers undefined block %s',
251
-        TEXT_HIGHLIGHTER_KEYWORD_INHERITS => 'Keyword group %s inherits undefined block %s',
252
-        TEXT_HIGHLIGHTER_PARSE => '%s',
253
-        TEXT_HIGHLIGHTER_FILE_WRITE => 'Error writing file %s',
254
-        TEXT_HIGHLIGHTER_FILE_READ => '%s'
255
-        );
256
-    }
257
-
258
-    // }}}
259
-    // {{{ setInputFile
260
-
261
-    /**
262
-    * Sets the input xml file to be parsed
263
-    *
264
-    * @param    string      Filename (full path)
265
-    * @return   boolean
266
-    * @access   public
267
-    */
268
-    function setInputFile($file)
269
-    {
270
-        $this->_syntaxFile = $file;
271
-        $ret = parent::setInputFile($file);
272
-        if (PEAR::isError($ret)) {
273
-            $this->_error(TEXT_HIGHLIGHTER_FILE_READ, $ret->message);
274
-            return false;
275
-        }
276
-        return true;
277
-    }
278
-
279
-    // }}}
280
-    // {{{ generate
281
-
282
-    /**
283
-    * Generates class code
284
-    *
285
-    * @access public
286
-    */
287
-
288
-    function generate()
289
-    {
290
-        $this->_regions    = array();
291
-        $this->_blocks     = array();
292
-        $this->_keywords   = array();
293
-        $this->language    = '';
294
-        $this->_code       = '';
295
-        $this->_defClass   = 'default';
296
-        $this->_comment    = '';
297
-        $this->_inComment  = false;
298
-        $this->_authors    = array();
299
-        $this->_blockOrder = 0;
300
-        $this->_errors   = array();
301
-
302
-        $ret = $this->parse();
303
-        if (PEAR::isError($ret)) {
304
-            $this->_error(TEXT_HIGHLIGHTER_PARSE, $ret->message);
305
-            return false;
306
-        }
307
-        return true;
308
-    }
309
-
310
-    // }}}
311
-    // {{{ getCode
312
-
313
-    /**
314
-    * Returns generated code as a string.
315
-    *
316
-    * @return string Generated code
317
-    * @access public
318
-    */
319
-
320
-    function getCode()
321
-    {
322
-        return $this->_code;
323
-    }
324
-
325
-    // }}}
326
-    // {{{ saveCode
327
-
328
-    /**
329
-    * Saves generated class to file. Note that {@link Text_Highlighter::factory()}
330
-    * assumes that filename is uppercase (SQL.php, DTD.php, etc), and file
331
-    * is located in Text/Highlighter
332
-    *
333
-    * @param string $filename Name of file to write the code to
334
-    * @return boolean true on success, false on failure
335
-    * @access public
336
-    */
337
-
338
-    function saveCode($filename)
339
-    {
340
-        $f = @fopen($filename, 'wb');
341
-        if (!$f) {
342
-            $this->_error(TEXT_HIGHLIGHTER_FILE_WRITE, array('outfile'=>$filename));
343
-            return false;
344
-        }
345
-        fwrite ($f, $this->_code);
346
-        fclose($f);
347
-        return true;
348
-    }
349
-
350
-    // }}}
351
-    // {{{ hasErrors
352
-
353
-    /**
354
-    * Reports if there were errors
355
-    *
356
-    * @return boolean
357
-    * @access public
358
-    */
359
-
360
-    function hasErrors()
361
-    {
362
-        return count($this->_errors) > 0;
363
-    }
364
-
365
-    // }}}
366
-    // {{{ getErrors
367
-
368
-    /**
369
-    * Returns errors
370
-    *
371
-    * @return array
372
-    * @access public
373
-    */
374
-
375
-    function getErrors()
376
-    {
377
-        return $this->_errors;
378
-    }
379
-
380
-    // }}}
381
-    // {{{ _sortBlocks
382
-
383
-    /**
384
-    * Sorts blocks
385
-    *
386
-    * @access private
387
-    */
388
-
389
-    function _sortBlocks($b1, $b2) {
390
-        return $b1['order'] - $b2['order'];
391
-    }
392
-
393
-    // }}}
394
-    // {{{ _sortLookFor
395
-    /**
396
-    * Sort 'look for' list
397
-    * @return int
398
-    * @param string $b1
399
-    * @param string $b2
400
-    */
401
-    function _sortLookFor($b1, $b2) {
402
-        $o1 = isset($this->_blocks[$b1]) ? $this->_blocks[$b1]['order'] : $this->_regions[$b1]['order'];
403
-        $o2 = isset($this->_blocks[$b2]) ? $this->_blocks[$b2]['order'] : $this->_regions[$b2]['order'];
404
-        return $o1 - $o2;
405
-    }
406
-
407
-    // }}}
408
-    // {{{ _makeRE
409
-
410
-    /**
411
-    * Adds delimiters and modifiers to regular expression if necessary
412
-    *
413
-    * @param string $text Original RE
414
-    * @return string Final RE
415
-    * @access private
416
-    */
417
-    function _makeRE($text, $case = false)
418
-    {
419
-        if (!strlen($text)) {
420
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_RE);
421
-        }
422
-        if (!strlen($text) || $text{0} != '/') {
423
-            $text = '/' . $text . '/';
424
-        }
425
-        if (!$case) {
426
-            $text .= 'i';
427
-        }
428
-        $php_errormsg = '';
429
-        @preg_match($text, '');
430
-        if ($php_errormsg) {
431
-            $this->_error(TEXT_HIGHLIGHTER_INVALID_RE, $php_errormsg);
432
-        }
433
-        preg_match ('#^/(.+)/(.*)$#', $text, $m);
434
-        if (@$m[2]) {
435
-            $text = '(?' . $m[2] . ')' . $m[1];
436
-        } else {
437
-            $text = $m[1];
438
-        }
439
-        return $text;
440
-    }
441
-
442
-    // }}}
443
-    // {{{ _exportArray
444
-
445
-    /**
446
-    * Exports array as PHP code
447
-    *
448
-    * @param array $array
449
-    * @return string Code
450
-    * @access private
451
-    */
452
-    function _exportArray($array)
453
-    {
454
-        $array = var_export($array, true);
455
-        return trim(preg_replace('~^(\s*)~m','        \1\1',$array));
456
-    }
457
-
458
-    // }}}
459
-    // {{{ _countSubpatterns
460
-    /**
461
-    * Find number of capturing suppaterns in regular expression
462
-    * @return int
463
-    * @param string $re Regular expression (without delimiters)
464
-    */
465
-    function _countSubpatterns($re)
466
-    {
467
-        preg_match_all('/' . $re . '/', '', $m);
468
-        return count($m)-1;
469
-    }
470
-
471
-    // }}}
472
-
473
-    /**#@+
70
+	// {{{ properties
71
+	/**
72
+	 * Whether to do case folding.
73
+	 * We have to declare it here, because XML_Parser
74
+	 * sets case folding in constructor
75
+	 *
76
+	 * @var  boolean
77
+	 */
78
+	var $folding = false;
79
+
80
+	/**
81
+	 * Holds name of file with highlighting rules
82
+	 *
83
+	 * @var string
84
+	 * @access private
85
+	 */
86
+	var $_syntaxFile;
87
+
88
+	/**
89
+	 * Current element being processed
90
+	 *
91
+	 * @var array
92
+	 * @access private
93
+	 */
94
+	var $_element;
95
+
96
+	/**
97
+	 * List of regions
98
+	 *
99
+	 * @var array
100
+	 * @access private
101
+	 */
102
+	var $_regions = array();
103
+
104
+	/**
105
+	 * List of blocks
106
+	 *
107
+	 * @var array
108
+	 * @access private
109
+	 */
110
+	var $_blocks = array();
111
+
112
+	/**
113
+	 * List of keyword groups
114
+	 *
115
+	 * @var array
116
+	 * @access private
117
+	 */
118
+	var $_keywords = array();
119
+
120
+	/**
121
+	 * List of authors
122
+	 *
123
+	 * @var array
124
+	 * @access private
125
+	 */
126
+	var $_authors = array();
127
+
128
+	/**
129
+	 * Name of language
130
+	 *
131
+	 * @var string
132
+	 * @access public
133
+	 */
134
+	var $language = '';
135
+
136
+	/**
137
+	 * Generated code
138
+	 *
139
+	 * @var string
140
+	 * @access private
141
+	 */
142
+	var $_code = '';
143
+
144
+	/**
145
+	 * Default class
146
+	 *
147
+	 * @var string
148
+	 * @access private
149
+	 */
150
+	var $_defClass = 'default';
151
+
152
+	/**
153
+	 * Comment
154
+	 *
155
+	 * @var string
156
+	 * @access private
157
+	 */
158
+	var $_comment = '';
159
+
160
+	/**
161
+	 * Flag for comment processing
162
+	 *
163
+	 * @var boolean
164
+	 * @access private
165
+	 */
166
+	var $_inComment = false;
167
+
168
+	/**
169
+	 * Sorting order of current block/region
170
+	 *
171
+	 * @var integer
172
+	 * @access private
173
+	 */
174
+	var $_blockOrder = 0;
175
+
176
+	/**
177
+	 * Generation errors
178
+	 *
179
+	 * @var array
180
+	 * @access private
181
+	 */
182
+	var $_errors;
183
+
184
+	// }}}
185
+	// {{{ constructor
186
+
187
+	/**
188
+	 * Constructor
189
+	 *
190
+	 * @param string $syntaxFile Name of XML file
191
+	 * with syntax highlighting rules
192
+	 *
193
+	 * @access public
194
+	 */
195
+
196
+	function __construct($syntaxFile = '')
197
+	{
198
+		XML_Parser::XML_Parser(null, 'func');
199
+		$this->_errors = array();
200
+		$this->_declareErrorMessages();
201
+		if ($syntaxFile) {
202
+			$this->setInputFile($syntaxFile);
203
+		}
204
+	}
205
+
206
+	// }}}
207
+	// {{{ _formatError
208
+
209
+	/**
210
+	 * Format error message
211
+	 *
212
+	 * @param int $code error code
213
+	 * @param string $params parameters
214
+	 * @param string $fileName file name
215
+	 * @param int $lineNo line number
216
+	 * @return  array
217
+	 * @access  public
218
+	 */
219
+	function _formatError($code, $params, $fileName, $lineNo)
220
+	{
221
+		$template = $this->_templates[$code];
222
+		$ret = call_user_func_array('sprintf', array_merge(array($template), $params));
223
+		if ($fileName) {
224
+			$ret = '[' . $fileName . '] ' . $ret;
225
+		}
226
+		if ($lineNo) {
227
+			$ret .= ' (line ' . $lineNo . ')';
228
+		}
229
+		return $ret;
230
+	}
231
+
232
+	// }}}
233
+	// {{{ declareErrorMessages
234
+
235
+	/**
236
+	 * Set up error message templates
237
+	 *
238
+	 * @access  private
239
+	 */
240
+	function _declareErrorMessages()
241
+	{
242
+		$this->_templates = array (
243
+		TEXT_HIGHLIGHTER_EMPTY_RE => 'Empty regular expression',
244
+		TEXT_HIGHLIGHTER_INVALID_RE => 'Invalid regular expression : %s',
245
+		TEXT_HIGHLIGHTER_EMPTY_OR_MISSING => 'Empty or missing %s',
246
+		TEXT_HIGHLIGHTER_EMPTY  => 'Empty %s',
247
+		TEXT_HIGHLIGHTER_REGION_REGION => 'Region %s refers undefined region %s',
248
+		TEXT_HIGHLIGHTER_REGION_BLOCK => 'Region %s refers undefined block %s',
249
+		TEXT_HIGHLIGHTER_BLOCK_REGION => 'Block %s refers undefined region %s',
250
+		TEXT_HIGHLIGHTER_KEYWORD_BLOCK => 'Keyword group %s refers undefined block %s',
251
+		TEXT_HIGHLIGHTER_KEYWORD_INHERITS => 'Keyword group %s inherits undefined block %s',
252
+		TEXT_HIGHLIGHTER_PARSE => '%s',
253
+		TEXT_HIGHLIGHTER_FILE_WRITE => 'Error writing file %s',
254
+		TEXT_HIGHLIGHTER_FILE_READ => '%s'
255
+		);
256
+	}
257
+
258
+	// }}}
259
+	// {{{ setInputFile
260
+
261
+	/**
262
+	 * Sets the input xml file to be parsed
263
+	 *
264
+	 * @param    string      Filename (full path)
265
+	 * @return   boolean
266
+	 * @access   public
267
+	 */
268
+	function setInputFile($file)
269
+	{
270
+		$this->_syntaxFile = $file;
271
+		$ret = parent::setInputFile($file);
272
+		if (PEAR::isError($ret)) {
273
+			$this->_error(TEXT_HIGHLIGHTER_FILE_READ, $ret->message);
274
+			return false;
275
+		}
276
+		return true;
277
+	}
278
+
279
+	// }}}
280
+	// {{{ generate
281
+
282
+	/**
283
+	 * Generates class code
284
+	 *
285
+	 * @access public
286
+	 */
287
+
288
+	function generate()
289
+	{
290
+		$this->_regions    = array();
291
+		$this->_blocks     = array();
292
+		$this->_keywords   = array();
293
+		$this->language    = '';
294
+		$this->_code       = '';
295
+		$this->_defClass   = 'default';
296
+		$this->_comment    = '';
297
+		$this->_inComment  = false;
298
+		$this->_authors    = array();
299
+		$this->_blockOrder = 0;
300
+		$this->_errors   = array();
301
+
302
+		$ret = $this->parse();
303
+		if (PEAR::isError($ret)) {
304
+			$this->_error(TEXT_HIGHLIGHTER_PARSE, $ret->message);
305
+			return false;
306
+		}
307
+		return true;
308
+	}
309
+
310
+	// }}}
311
+	// {{{ getCode
312
+
313
+	/**
314
+	 * Returns generated code as a string.
315
+	 *
316
+	 * @return string Generated code
317
+	 * @access public
318
+	 */
319
+
320
+	function getCode()
321
+	{
322
+		return $this->_code;
323
+	}
324
+
325
+	// }}}
326
+	// {{{ saveCode
327
+
328
+	/**
329
+	 * Saves generated class to file. Note that {@link Text_Highlighter::factory()}
330
+	 * assumes that filename is uppercase (SQL.php, DTD.php, etc), and file
331
+	 * is located in Text/Highlighter
332
+	 *
333
+	 * @param string $filename Name of file to write the code to
334
+	 * @return boolean true on success, false on failure
335
+	 * @access public
336
+	 */
337
+
338
+	function saveCode($filename)
339
+	{
340
+		$f = @fopen($filename, 'wb');
341
+		if (!$f) {
342
+			$this->_error(TEXT_HIGHLIGHTER_FILE_WRITE, array('outfile'=>$filename));
343
+			return false;
344
+		}
345
+		fwrite ($f, $this->_code);
346
+		fclose($f);
347
+		return true;
348
+	}
349
+
350
+	// }}}
351
+	// {{{ hasErrors
352
+
353
+	/**
354
+	 * Reports if there were errors
355
+	 *
356
+	 * @return boolean
357
+	 * @access public
358
+	 */
359
+
360
+	function hasErrors()
361
+	{
362
+		return count($this->_errors) > 0;
363
+	}
364
+
365
+	// }}}
366
+	// {{{ getErrors
367
+
368
+	/**
369
+	 * Returns errors
370
+	 *
371
+	 * @return array
372
+	 * @access public
373
+	 */
374
+
375
+	function getErrors()
376
+	{
377
+		return $this->_errors;
378
+	}
379
+
380
+	// }}}
381
+	// {{{ _sortBlocks
382
+
383
+	/**
384
+	 * Sorts blocks
385
+	 *
386
+	 * @access private
387
+	 */
388
+
389
+	function _sortBlocks($b1, $b2) {
390
+		return $b1['order'] - $b2['order'];
391
+	}
392
+
393
+	// }}}
394
+	// {{{ _sortLookFor
395
+	/**
396
+	 * Sort 'look for' list
397
+	 * @return int
398
+	 * @param string $b1
399
+	 * @param string $b2
400
+	 */
401
+	function _sortLookFor($b1, $b2) {
402
+		$o1 = isset($this->_blocks[$b1]) ? $this->_blocks[$b1]['order'] : $this->_regions[$b1]['order'];
403
+		$o2 = isset($this->_blocks[$b2]) ? $this->_blocks[$b2]['order'] : $this->_regions[$b2]['order'];
404
+		return $o1 - $o2;
405
+	}
406
+
407
+	// }}}
408
+	// {{{ _makeRE
409
+
410
+	/**
411
+	 * Adds delimiters and modifiers to regular expression if necessary
412
+	 *
413
+	 * @param string $text Original RE
414
+	 * @return string Final RE
415
+	 * @access private
416
+	 */
417
+	function _makeRE($text, $case = false)
418
+	{
419
+		if (!strlen($text)) {
420
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_RE);
421
+		}
422
+		if (!strlen($text) || $text{0} != '/') {
423
+			$text = '/' . $text . '/';
424
+		}
425
+		if (!$case) {
426
+			$text .= 'i';
427
+		}
428
+		$php_errormsg = '';
429
+		@preg_match($text, '');
430
+		if ($php_errormsg) {
431
+			$this->_error(TEXT_HIGHLIGHTER_INVALID_RE, $php_errormsg);
432
+		}
433
+		preg_match ('#^/(.+)/(.*)$#', $text, $m);
434
+		if (@$m[2]) {
435
+			$text = '(?' . $m[2] . ')' . $m[1];
436
+		} else {
437
+			$text = $m[1];
438
+		}
439
+		return $text;
440
+	}
441
+
442
+	// }}}
443
+	// {{{ _exportArray
444
+
445
+	/**
446
+	 * Exports array as PHP code
447
+	 *
448
+	 * @param array $array
449
+	 * @return string Code
450
+	 * @access private
451
+	 */
452
+	function _exportArray($array)
453
+	{
454
+		$array = var_export($array, true);
455
+		return trim(preg_replace('~^(\s*)~m','        \1\1',$array));
456
+	}
457
+
458
+	// }}}
459
+	// {{{ _countSubpatterns
460
+	/**
461
+	 * Find number of capturing suppaterns in regular expression
462
+	 * @return int
463
+	 * @param string $re Regular expression (without delimiters)
464
+	 */
465
+	function _countSubpatterns($re)
466
+	{
467
+		preg_match_all('/' . $re . '/', '', $m);
468
+		return count($m)-1;
469
+	}
470
+
471
+	// }}}
472
+
473
+	/**#@+
474 474
     * @access private
475 475
     * @param resource $xp      XML parser resource
476 476
     * @param string   $elem    XML element name
477 477
     * @param array    $attribs XML element attributes
478 478
     */
479 479
 
480
-    // {{{ xmltag_Default
481
-
482
-    /**
483
-    * start handler for <default> element
484
-    */
485
-    function xmltag_Default($xp, $elem, $attribs)
486
-    {
487
-        $this->_aliasAttributes($attribs);
488
-        if (!isset($attribs['innerGroup']) || $attribs['innerGroup'] === '') {
489
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'innerGroup');
490
-        }
491
-        $this->_defClass = @$attribs['innerGroup'];
492
-    }
493
-
494
-    // }}}
495
-    // {{{ xmltag_Region
496
-
497
-    /**
498
-    * start handler for <region> element
499
-    */
500
-    function xmltag_Region($xp, $elem, $attribs)
501
-    {
502
-        $this->_aliasAttributes($attribs);
503
-        if (!isset($attribs['name']) || $attribs['name'] === '') {
504
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'region name');
505
-        }
506
-        if (!isset($attribs['innerGroup']) || $attribs['innerGroup'] === '') {
507
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'innerGroup');
508
-        }
509
-        $this->_element = array('name' => $attribs['name']);
510
-        $this->_element['line'] = xml_get_current_line_number($this->parser);
511
-        if (isset($attribs['case'])) {
512
-            $this->_element['case'] = $attribs['case'] == 'yes';
513
-        } else {
514
-            $this->_element['case'] = $this->_case;
515
-        }
516
-        $this->_element['innerGroup'] = $attribs['innerGroup'];
517
-        $this->_element['delimGroup'] = isset($attribs['delimGroup']) ?
518
-        $attribs['delimGroup'] :
519
-        $attribs['innerGroup'];
520
-        $this->_element['start'] = $this->_makeRE(@$attribs['start'], $this->_element['case']);
521
-        $this->_element['end'] = $this->_makeRE(@$attribs['end'], $this->_element['case']);
522
-        $this->_element['contained'] = @$attribs['contained'] == 'yes';
523
-        $this->_element['never-contained'] = @$attribs['never-contained'] == 'yes';
524
-        $this->_element['remember'] = @$attribs['remember'] == 'yes';
525
-        if (isset($attribs['startBOL']) && $attribs['startBOL'] == 'yes') {
526
-            $this->_element['startBOL'] = true;
527
-        }
528
-        if (isset($attribs['endBOL']) && $attribs['endBOL'] == 'yes') {
529
-            $this->_element['endBOL'] = true;
530
-        }
531
-        if (isset($attribs['neverAfter'])) {
532
-            $this->_element['neverafter'] = $this->_makeRE($attribs['neverAfter']);
533
-        }
534
-    }
535
-
536
-    // }}}
537
-    // {{{ xmltag_Block
538
-
539
-    /**
540
-    * start handler for <block> element
541
-    */
542
-    function xmltag_Block($xp, $elem, $attribs)
543
-    {
544
-        $this->_aliasAttributes($attribs);
545
-        if (!isset($attribs['name']) || $attribs['name'] === '') {
546
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'block name');
547
-        }
548
-        if (isset($attribs['innerGroup']) && $attribs['innerGroup'] === '') {
549
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY, 'innerGroup');
550
-        }
551
-        $this->_element = array('name' => $attribs['name']);
552
-        $this->_element['line'] = xml_get_current_line_number($this->parser);
553
-        if (isset($attribs['case'])) {
554
-            $this->_element['case'] = $attribs['case'] == 'yes';
555
-        } else {
556
-            $this->_element['case'] = $this->_case;
557
-        }
558
-        if (isset($attribs['innerGroup'])) {
559
-            $this->_element['innerGroup'] = @$attribs['innerGroup'];
560
-        }
561
-        $this->_element['match'] = $this->_makeRE($attribs['match'], $this->_element['case']);
562
-        $this->_element['contained'] = @$attribs['contained'] == 'yes';
563
-        $this->_element['multiline'] = @$attribs['multiline'] == 'yes';
564
-        if (isset($attribs['BOL']) && $attribs['BOL'] == 'yes') {
565
-            $this->_element['BOL'] = true;
566
-        }
567
-        if (isset($attribs['neverAfter'])) {
568
-            $this->_element['neverafter'] = $this->_makeRE($attribs['neverAfter']);
569
-        }
570
-    }
571
-
572
-    // }}}
573
-    // {{{ cdataHandler
574
-
575
-    /**
576
-    * Character data handler. Used for comment
577
-    */
578
-    function cdataHandler($xp, $cdata)
579
-    {
580
-        if ($this->_inComment) {
581
-            $this->_comment .= $cdata;
582
-        }
583
-    }
584
-
585
-    // }}}
586
-    // {{{ xmltag_Comment
587
-
588
-    /**
589
-    * start handler for <comment> element
590
-    */
591
-    function xmltag_Comment($xp, $elem, $attribs)
592
-    {
593
-        $this->_comment = '';
594
-        $this->_inComment = true;
595
-    }
596
-
597
-    // }}}
598
-    // {{{ xmltag_PartGroup
599
-
600
-    /**
601
-    * start handler for <partgroup> element
602
-    */
603
-    function xmltag_PartGroup($xp, $elem, $attribs)
604
-    {
605
-        $this->_aliasAttributes($attribs);
606
-        if (!isset($attribs['innerGroup']) || $attribs['innerGroup'] === '') {
607
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'innerGroup');
608
-        }
609
-        $this->_element['partClass'][$attribs['index']] = @$attribs['innerGroup'];
610
-    }
611
-
612
-    // }}}
613
-    // {{{ xmltag_PartClass
614
-
615
-    /**
616
-    * start handler for <partclass> element
617
-    */
618
-    function xmltag_PartClass($xp, $elem, $attribs)
619
-    {
620
-        $this->xmltag_PartGroup($xp, $elem, $attribs);
621
-    }
622
-
623
-    // }}}
624
-    // {{{ xmltag_Keywords
625
-
626
-    /**
627
-    * start handler for <keywords> element
628
-    */
629
-    function xmltag_Keywords($xp, $elem, $attribs)
630
-    {
631
-        $this->_aliasAttributes($attribs);
632
-        if (!isset($attribs['name']) || $attribs['name'] === '') {
633
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'keyword group name');
634
-        }
635
-        if (!isset($attribs['innerGroup']) || $attribs['innerGroup'] === '') {
636
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'innerGroup');
637
-        }
638
-        if (!isset($attribs['inherits']) || $attribs['inherits'] === '') {
639
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'inherits');
640
-        }
641
-        $this->_element = array('name'=>@$attribs['name']);
642
-        $this->_element['line'] = xml_get_current_line_number($this->parser);
643
-        $this->_element['innerGroup'] = @$attribs['innerGroup'];
644
-        if (isset($attribs['case'])) {
645
-            $this->_element['case'] = $attribs['case'] == 'yes';
646
-        } else {
647
-            $this->_element['case'] = $this->_case;
648
-        }
649
-        $this->_element['inherits'] = @$attribs['inherits'];
650
-        if (isset($attribs['otherwise'])) {
651
-            $this->_element['otherwise'] = $attribs['otherwise'];
652
-        }
653
-        if (isset($attribs['ifdef'])) {
654
-            $this->_element['ifdef'] = $attribs['ifdef'];
655
-        }
656
-        if (isset($attribs['ifndef'])) {
657
-            $this->_element['ifndef'] = $attribs['ifndef'];
658
-        }
659
-    }
660
-
661
-    // }}}
662
-    // {{{ xmltag_Keyword
663
-
664
-    /**
665
-    * start handler for <keyword> element
666
-    */
667
-    function xmltag_Keyword($xp, $elem, $attribs)
668
-    {
669
-        if (!isset($attribs['match']) || $attribs['match'] === '') {
670
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'match');
671
-        }
672
-        $keyword = @$attribs['match'];
673
-        if (!$this->_element['case']) {
674
-            $keyword = strtolower($keyword);
675
-        }
676
-        $this->_element['match'][$keyword] = true;
677
-    }
678
-
679
-    // }}}
680
-    // {{{ xmltag_Contains
681
-
682
-    /**
683
-    * start handler for <contains> element
684
-    */
685
-    function xmltag_Contains($xp, $elem, $attribs)
686
-    {
687
-        $this->_element['contains-all'] = @$attribs['all'] == 'yes';
688
-        if (isset($attribs['region'])) {
689
-            $this->_element['contains']['region'][$attribs['region']] =
690
-            xml_get_current_line_number($this->parser);
691
-        }
692
-        if (isset($attribs['block'])) {
693
-            $this->_element['contains']['block'][$attribs['block']] =
694
-            xml_get_current_line_number($this->parser);
695
-        }
696
-    }
697
-
698
-    // }}}
699
-    // {{{ xmltag_But
700
-
701
-    /**
702
-    * start handler for <but> element
703
-    */
704
-    function xmltag_But($xp, $elem, $attribs)
705
-    {
706
-        if (isset($attribs['region'])) {
707
-            $this->_element['not-contains']['region'][$attribs['region']] = true;
708
-        }
709
-        if (isset($attribs['block'])) {
710
-            $this->_element['not-contains']['block'][$attribs['block']] = true;
711
-        }
712
-    }
713
-
714
-    // }}}
715
-    // {{{ xmltag_Onlyin
716
-
717
-    /**
718
-    * start handler for <onlyin> element
719
-    */
720
-    function xmltag_Onlyin($xp, $elem, $attribs)
721
-    {
722
-        if (!isset($attribs['region']) || $attribs['region'] === '') {
723
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'region');
724
-        }
725
-        $this->_element['onlyin'][$attribs['region']] = xml_get_current_line_number($this->parser);
726
-    }
727
-
728
-    // }}}
729
-    // {{{ xmltag_Author
730
-
731
-    /**
732
-    * start handler for <author> element
733
-    */
734
-    function xmltag_Author($xp, $elem, $attribs)
735
-    {
736
-        if (!isset($attribs['name']) || $attribs['name'] === '') {
737
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'author name');
738
-        }
739
-        $this->_authors[] = array(
740
-        'name'  => @$attribs['name'],
741
-        'email' => (string)@$attribs['email']
742
-        );
743
-    }
744
-
745
-    // }}}
746
-    // {{{ xmltag_Highlight
747
-
748
-    /**
749
-    * start handler for <highlight> element
750
-    */
751
-    function xmltag_Highlight($xp, $elem, $attribs)
752
-    {
753
-        if (!isset($attribs['lang']) || $attribs['lang'] === '') {
754
-            $this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'language name');
755
-        }
756
-        $this->_code = '';
757
-        $this->language = strtoupper(@$attribs['lang']);
758
-        $this->_case = @$attribs['case'] == 'yes';
759
-    }
760
-
761
-    // }}}
762
-
763
-    /**#@-*/
764
-
765
-    // {{{ _error
766
-
767
-    /**
768
-    * Add an error message
769
-    *
770
-    * @param integer $code Error code
771
-    * @param mixed   $message Error message or array with error message parameters
772
-    * @param integer $lineNo Source code line number
773
-    * @access private
774
-    */
775
-    function _error($code, $params = array(), $lineNo = 0)
776
-    {
777
-        if (!$lineNo && !empty($this->parser)) {
778
-            $lineNo = xml_get_current_line_number($this->parser);
779
-        }
780
-        $this->_errors[] = $this->_formatError($code, $params, $this->_syntaxFile, $lineNo);
781
-    }
782
-
783
-    // }}}
784
-    // {{{ _aliasAttributes
785
-
786
-    /**
787
-    * BC trick
788
-    *
789
-    * @param array $attrs attributes
790
-    */
791
-    function _aliasAttributes(&$attrs)
792
-    {
793
-        if (isset($attrs['innerClass']) && !isset($attrs['innerGroup'])) {
794
-            $attrs['innerGroup'] = $attrs['innerClass'];
795
-        }
796
-        if (isset($attrs['delimClass']) && !isset($attrs['delimGroup'])) {
797
-            $attrs['delimGroup'] = $attrs['delimClass'];
798
-        }
799
-        if (isset($attrs['partClass']) && !isset($attrs['partGroup'])) {
800
-            $attrs['partGroup'] = $attrs['partClass'];
801
-        }
802
-    }
803
-
804
-    // }}}
805
-
806
-    /**#@+
480
+	// {{{ xmltag_Default
481
+
482
+	/**
483
+	 * start handler for <default> element
484
+	 */
485
+	function xmltag_Default($xp, $elem, $attribs)
486
+	{
487
+		$this->_aliasAttributes($attribs);
488
+		if (!isset($attribs['innerGroup']) || $attribs['innerGroup'] === '') {
489
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'innerGroup');
490
+		}
491
+		$this->_defClass = @$attribs['innerGroup'];
492
+	}
493
+
494
+	// }}}
495
+	// {{{ xmltag_Region
496
+
497
+	/**
498
+	 * start handler for <region> element
499
+	 */
500
+	function xmltag_Region($xp, $elem, $attribs)
501
+	{
502
+		$this->_aliasAttributes($attribs);
503
+		if (!isset($attribs['name']) || $attribs['name'] === '') {
504
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'region name');
505
+		}
506
+		if (!isset($attribs['innerGroup']) || $attribs['innerGroup'] === '') {
507
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'innerGroup');
508
+		}
509
+		$this->_element = array('name' => $attribs['name']);
510
+		$this->_element['line'] = xml_get_current_line_number($this->parser);
511
+		if (isset($attribs['case'])) {
512
+			$this->_element['case'] = $attribs['case'] == 'yes';
513
+		} else {
514
+			$this->_element['case'] = $this->_case;
515
+		}
516
+		$this->_element['innerGroup'] = $attribs['innerGroup'];
517
+		$this->_element['delimGroup'] = isset($attribs['delimGroup']) ?
518
+		$attribs['delimGroup'] :
519
+		$attribs['innerGroup'];
520
+		$this->_element['start'] = $this->_makeRE(@$attribs['start'], $this->_element['case']);
521
+		$this->_element['end'] = $this->_makeRE(@$attribs['end'], $this->_element['case']);
522
+		$this->_element['contained'] = @$attribs['contained'] == 'yes';
523
+		$this->_element['never-contained'] = @$attribs['never-contained'] == 'yes';
524
+		$this->_element['remember'] = @$attribs['remember'] == 'yes';
525
+		if (isset($attribs['startBOL']) && $attribs['startBOL'] == 'yes') {
526
+			$this->_element['startBOL'] = true;
527
+		}
528
+		if (isset($attribs['endBOL']) && $attribs['endBOL'] == 'yes') {
529
+			$this->_element['endBOL'] = true;
530
+		}
531
+		if (isset($attribs['neverAfter'])) {
532
+			$this->_element['neverafter'] = $this->_makeRE($attribs['neverAfter']);
533
+		}
534
+	}
535
+
536
+	// }}}
537
+	// {{{ xmltag_Block
538
+
539
+	/**
540
+	 * start handler for <block> element
541
+	 */
542
+	function xmltag_Block($xp, $elem, $attribs)
543
+	{
544
+		$this->_aliasAttributes($attribs);
545
+		if (!isset($attribs['name']) || $attribs['name'] === '') {
546
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'block name');
547
+		}
548
+		if (isset($attribs['innerGroup']) && $attribs['innerGroup'] === '') {
549
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY, 'innerGroup');
550
+		}
551
+		$this->_element = array('name' => $attribs['name']);
552
+		$this->_element['line'] = xml_get_current_line_number($this->parser);
553
+		if (isset($attribs['case'])) {
554
+			$this->_element['case'] = $attribs['case'] == 'yes';
555
+		} else {
556
+			$this->_element['case'] = $this->_case;
557
+		}
558
+		if (isset($attribs['innerGroup'])) {
559
+			$this->_element['innerGroup'] = @$attribs['innerGroup'];
560
+		}
561
+		$this->_element['match'] = $this->_makeRE($attribs['match'], $this->_element['case']);
562
+		$this->_element['contained'] = @$attribs['contained'] == 'yes';
563
+		$this->_element['multiline'] = @$attribs['multiline'] == 'yes';
564
+		if (isset($attribs['BOL']) && $attribs['BOL'] == 'yes') {
565
+			$this->_element['BOL'] = true;
566
+		}
567
+		if (isset($attribs['neverAfter'])) {
568
+			$this->_element['neverafter'] = $this->_makeRE($attribs['neverAfter']);
569
+		}
570
+	}
571
+
572
+	// }}}
573
+	// {{{ cdataHandler
574
+
575
+	/**
576
+	 * Character data handler. Used for comment
577
+	 */
578
+	function cdataHandler($xp, $cdata)
579
+	{
580
+		if ($this->_inComment) {
581
+			$this->_comment .= $cdata;
582
+		}
583
+	}
584
+
585
+	// }}}
586
+	// {{{ xmltag_Comment
587
+
588
+	/**
589
+	 * start handler for <comment> element
590
+	 */
591
+	function xmltag_Comment($xp, $elem, $attribs)
592
+	{
593
+		$this->_comment = '';
594
+		$this->_inComment = true;
595
+	}
596
+
597
+	// }}}
598
+	// {{{ xmltag_PartGroup
599
+
600
+	/**
601
+	 * start handler for <partgroup> element
602
+	 */
603
+	function xmltag_PartGroup($xp, $elem, $attribs)
604
+	{
605
+		$this->_aliasAttributes($attribs);
606
+		if (!isset($attribs['innerGroup']) || $attribs['innerGroup'] === '') {
607
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'innerGroup');
608
+		}
609
+		$this->_element['partClass'][$attribs['index']] = @$attribs['innerGroup'];
610
+	}
611
+
612
+	// }}}
613
+	// {{{ xmltag_PartClass
614
+
615
+	/**
616
+	 * start handler for <partclass> element
617
+	 */
618
+	function xmltag_PartClass($xp, $elem, $attribs)
619
+	{
620
+		$this->xmltag_PartGroup($xp, $elem, $attribs);
621
+	}
622
+
623
+	// }}}
624
+	// {{{ xmltag_Keywords
625
+
626
+	/**
627
+	 * start handler for <keywords> element
628
+	 */
629
+	function xmltag_Keywords($xp, $elem, $attribs)
630
+	{
631
+		$this->_aliasAttributes($attribs);
632
+		if (!isset($attribs['name']) || $attribs['name'] === '') {
633
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'keyword group name');
634
+		}
635
+		if (!isset($attribs['innerGroup']) || $attribs['innerGroup'] === '') {
636
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'innerGroup');
637
+		}
638
+		if (!isset($attribs['inherits']) || $attribs['inherits'] === '') {
639
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'inherits');
640
+		}
641
+		$this->_element = array('name'=>@$attribs['name']);
642
+		$this->_element['line'] = xml_get_current_line_number($this->parser);
643
+		$this->_element['innerGroup'] = @$attribs['innerGroup'];
644
+		if (isset($attribs['case'])) {
645
+			$this->_element['case'] = $attribs['case'] == 'yes';
646
+		} else {
647
+			$this->_element['case'] = $this->_case;
648
+		}
649
+		$this->_element['inherits'] = @$attribs['inherits'];
650
+		if (isset($attribs['otherwise'])) {
651
+			$this->_element['otherwise'] = $attribs['otherwise'];
652
+		}
653
+		if (isset($attribs['ifdef'])) {
654
+			$this->_element['ifdef'] = $attribs['ifdef'];
655
+		}
656
+		if (isset($attribs['ifndef'])) {
657
+			$this->_element['ifndef'] = $attribs['ifndef'];
658
+		}
659
+	}
660
+
661
+	// }}}
662
+	// {{{ xmltag_Keyword
663
+
664
+	/**
665
+	 * start handler for <keyword> element
666
+	 */
667
+	function xmltag_Keyword($xp, $elem, $attribs)
668
+	{
669
+		if (!isset($attribs['match']) || $attribs['match'] === '') {
670
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'match');
671
+		}
672
+		$keyword = @$attribs['match'];
673
+		if (!$this->_element['case']) {
674
+			$keyword = strtolower($keyword);
675
+		}
676
+		$this->_element['match'][$keyword] = true;
677
+	}
678
+
679
+	// }}}
680
+	// {{{ xmltag_Contains
681
+
682
+	/**
683
+	 * start handler for <contains> element
684
+	 */
685
+	function xmltag_Contains($xp, $elem, $attribs)
686
+	{
687
+		$this->_element['contains-all'] = @$attribs['all'] == 'yes';
688
+		if (isset($attribs['region'])) {
689
+			$this->_element['contains']['region'][$attribs['region']] =
690
+			xml_get_current_line_number($this->parser);
691
+		}
692
+		if (isset($attribs['block'])) {
693
+			$this->_element['contains']['block'][$attribs['block']] =
694
+			xml_get_current_line_number($this->parser);
695
+		}
696
+	}
697
+
698
+	// }}}
699
+	// {{{ xmltag_But
700
+
701
+	/**
702
+	 * start handler for <but> element
703
+	 */
704
+	function xmltag_But($xp, $elem, $attribs)
705
+	{
706
+		if (isset($attribs['region'])) {
707
+			$this->_element['not-contains']['region'][$attribs['region']] = true;
708
+		}
709
+		if (isset($attribs['block'])) {
710
+			$this->_element['not-contains']['block'][$attribs['block']] = true;
711
+		}
712
+	}
713
+
714
+	// }}}
715
+	// {{{ xmltag_Onlyin
716
+
717
+	/**
718
+	 * start handler for <onlyin> element
719
+	 */
720
+	function xmltag_Onlyin($xp, $elem, $attribs)
721
+	{
722
+		if (!isset($attribs['region']) || $attribs['region'] === '') {
723
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'region');
724
+		}
725
+		$this->_element['onlyin'][$attribs['region']] = xml_get_current_line_number($this->parser);
726
+	}
727
+
728
+	// }}}
729
+	// {{{ xmltag_Author
730
+
731
+	/**
732
+	 * start handler for <author> element
733
+	 */
734
+	function xmltag_Author($xp, $elem, $attribs)
735
+	{
736
+		if (!isset($attribs['name']) || $attribs['name'] === '') {
737
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'author name');
738
+		}
739
+		$this->_authors[] = array(
740
+		'name'  => @$attribs['name'],
741
+		'email' => (string)@$attribs['email']
742
+		);
743
+	}
744
+
745
+	// }}}
746
+	// {{{ xmltag_Highlight
747
+
748
+	/**
749
+	 * start handler for <highlight> element
750
+	 */
751
+	function xmltag_Highlight($xp, $elem, $attribs)
752
+	{
753
+		if (!isset($attribs['lang']) || $attribs['lang'] === '') {
754
+			$this->_error(TEXT_HIGHLIGHTER_EMPTY_OR_MISSING, 'language name');
755
+		}
756
+		$this->_code = '';
757
+		$this->language = strtoupper(@$attribs['lang']);
758
+		$this->_case = @$attribs['case'] == 'yes';
759
+	}
760
+
761
+	// }}}
762
+
763
+	/**#@-*/
764
+
765
+	// {{{ _error
766
+
767
+	/**
768
+	 * Add an error message
769
+	 *
770
+	 * @param integer $code Error code
771
+	 * @param mixed   $message Error message or array with error message parameters
772
+	 * @param integer $lineNo Source code line number
773
+	 * @access private
774
+	 */
775
+	function _error($code, $params = array(), $lineNo = 0)
776
+	{
777
+		if (!$lineNo && !empty($this->parser)) {
778
+			$lineNo = xml_get_current_line_number($this->parser);
779
+		}
780
+		$this->_errors[] = $this->_formatError($code, $params, $this->_syntaxFile, $lineNo);
781
+	}
782
+
783
+	// }}}
784
+	// {{{ _aliasAttributes
785
+
786
+	/**
787
+	 * BC trick
788
+	 *
789
+	 * @param array $attrs attributes
790
+	 */
791
+	function _aliasAttributes(&$attrs)
792
+	{
793
+		if (isset($attrs['innerClass']) && !isset($attrs['innerGroup'])) {
794
+			$attrs['innerGroup'] = $attrs['innerClass'];
795
+		}
796
+		if (isset($attrs['delimClass']) && !isset($attrs['delimGroup'])) {
797
+			$attrs['delimGroup'] = $attrs['delimClass'];
798
+		}
799
+		if (isset($attrs['partClass']) && !isset($attrs['partGroup'])) {
800
+			$attrs['partGroup'] = $attrs['partClass'];
801
+		}
802
+	}
803
+
804
+	// }}}
805
+
806
+	/**#@+
807 807
     * @access private
808 808
     * @param resource $xp      XML parser resource
809 809
     * @param string   $elem    XML element name
810 810
     */
811 811
 
812
-    // {{{ xmltag_Comment_
813
-
814
-    /**
815
-    * end handler for <comment> element
816
-    */
817
-    function xmltag_Comment_($xp, $elem)
818
-    {
819
-        $this->_inComment = false;
820
-    }
821
-
822
-    // }}}
823
-    // {{{ xmltag_Region_
824
-
825
-    /**
826
-    * end handler for <region> element
827
-    */
828
-    function xmltag_Region_($xp, $elem)
829
-    {
830
-        $this->_element['type'] = 'region';
831
-        $this->_element['order'] = $this->_blockOrder ++;
832
-        $this->_regions[$this->_element['name']] = $this->_element;
833
-    }
834
-
835
-    // }}}
836
-    // {{{ xmltag_Keywords_
837
-
838
-    /**
839
-    * end handler for <keywords> element
840
-    */
841
-    function xmltag_Keywords_($xp, $elem)
842
-    {
843
-        $this->_keywords[$this->_element['name']] = $this->_element;
844
-    }
845
-
846
-    // }}}
847
-    // {{{ xmltag_Block_
848
-
849
-    /**
850
-    * end handler for <block> element
851
-    */
852
-    function xmltag_Block_($xp, $elem)
853
-    {
854
-        $this->_element['type'] = 'block';
855
-        $this->_element['order'] = $this->_blockOrder ++;
856
-        $this->_blocks[$this->_element['name']] = $this->_element;
857
-    }
858
-
859
-    // }}}
860
-    // {{{ xmltag_Highlight_
861
-
862
-    /**
863
-    * end handler for <highlight> element
864
-    */
865
-    function xmltag_Highlight_($xp, $elem)
866
-    {
867
-        $conditions = array();
868
-        $toplevel = array();
869
-        foreach ($this->_blocks as $i => $current) {
870
-            if (!$current['contained'] && !isset($current['onlyin'])) {
871
-                $toplevel[] = $i;
872
-            }
873
-            foreach ((array)@$current['onlyin'] as $region => $lineNo) {
874
-                if (!isset($this->_regions[$region])) {
875
-                    $this->_error(TEXT_HIGHLIGHTER_BLOCK_REGION,
876
-                    array(
877
-                    'block' => $current['name'],
878
-                    'region' => $region
879
-                    ));
880
-                }
881
-            }
882
-        }
883
-        foreach ($this->_regions as $i=>$current) {
884
-            if (!$current['contained'] && !isset($current['onlyin'])) {
885
-                $toplevel[] = $i;
886
-            }
887
-            foreach ((array)@$current['contains']['region'] as $region => $lineNo) {
888
-                if (!isset($this->_regions[$region])) {
889
-                    $this->_error(TEXT_HIGHLIGHTER_REGION_REGION,
890
-                    array(
891
-                    'region1' => $current['name'],
892
-                    'region2' => $region
893
-                    ));
894
-                }
895
-            }
896
-            foreach ((array)@$current['contains']['block'] as $region => $lineNo) {
897
-                if (!isset($this->_blocks[$region])) {
898
-                    $this->_error(TEXT_HIGHLIGHTER_REGION_BLOCK,
899
-                    array(
900
-                    'block' => $current['name'],
901
-                    'region' => $region
902
-                    ));
903
-                }
904
-            }
905
-            foreach ((array)@$current['onlyin'] as $region => $lineNo) {
906
-                if (!isset($this->_regions[$region])) {
907
-                    $this->_error(TEXT_HIGHLIGHTER_REGION_REGION,
908
-                    array(
909
-                    'region1' => $current['name'],
910
-                    'region2' => $region
911
-                    ));
912
-                }
913
-            }
914
-            foreach ($this->_regions as $j => $region) {
915
-                if (isset($region['onlyin'])) {
916
-                    $suits = isset($region['onlyin'][$current['name']]);
917
-                } elseif (isset($current['not-contains']['region'][$region['name']])) {
918
-                    $suits = false;
919
-                } elseif (isset($current['contains']['region'][$region['name']])) {
920
-                    $suits = true;
921
-                } else {
922
-                    $suits = @$current['contains-all'] && @!$region['never-contained'];
923
-                }
924
-                if ($suits) {
925
-                    $this->_regions[$i]['lookfor'][] = $j;
926
-                }
927
-            }
928
-            foreach ($this->_blocks as $j=>$region) {
929
-                if (isset($region['onlyin'])) {
930
-                    $suits = isset($region['onlyin'][$current['name']]);
931
-                } elseif (isset($current['not-contains']['block'][$region['name']])) {
932
-                    $suits = false;
933
-                } elseif (isset($current['contains']['block'][$region['name']])) {
934
-                    $suits = true;
935
-                } else {
936
-                    $suits = @$current['contains-all'] && @!$region['never-contained'];
937
-                }
938
-                if ($suits) {
939
-                    $this->_regions[$i]['lookfor'][] = $j;
940
-                }
941
-            }
942
-        }
943
-        foreach ($this->_blocks as $i=>$current) {
944
-            unset ($this->_blocks[$i]['never-contained']);
945
-            unset ($this->_blocks[$i]['contained']);
946
-            unset ($this->_blocks[$i]['contains-all']);
947
-            unset ($this->_blocks[$i]['contains']);
948
-            unset ($this->_blocks[$i]['onlyin']);
949
-            unset ($this->_blocks[$i]['line']);
950
-        }
951
-
952
-        foreach ($this->_regions as $i=>$current) {
953
-            unset ($this->_regions[$i]['never-contained']);
954
-            unset ($this->_regions[$i]['contained']);
955
-            unset ($this->_regions[$i]['contains-all']);
956
-            unset ($this->_regions[$i]['contains']);
957
-            unset ($this->_regions[$i]['onlyin']);
958
-            unset ($this->_regions[$i]['line']);
959
-        }
960
-
961
-        foreach ($this->_keywords as $name => $keyword) {
962
-            if (isset($keyword['ifdef'])) {
963
-                $conditions[$keyword['ifdef']][] = array($name, true);
964
-            }
965
-            if (isset($keyword['ifndef'])) {
966
-                $conditions[$keyword['ifndef']][] = array($name, false);
967
-            }
968
-            unset($this->_keywords[$name]['line']);
969
-            if (!isset($this->_blocks[$keyword['inherits']])) {
970
-                $this->_error(TEXT_HIGHLIGHTER_KEYWORD_INHERITS,
971
-                array(
972
-                'keyword' => $keyword['name'],
973
-                'block' => $keyword['inherits']
974
-                ));
975
-            }
976
-            if (isset($keyword['otherwise']) && !isset($this->_blocks[$keyword['otherwise']]) ) {
977
-                $this->_error(TEXT_HIGHLIGHTER_KEYWORD_BLOCK,
978
-                array(
979
-                'keyword' => $keyword['name'],
980
-                'block' => $keyword['inherits']
981
-                ));
982
-            }
983
-        }
984
-
985
-        $syntax=array(
986
-        'keywords'   => $this->_keywords,
987
-        'blocks'     => array_merge($this->_blocks, $this->_regions),
988
-        'toplevel'   => $toplevel,
989
-        );
990
-        uasort($syntax['blocks'], array(&$this, '_sortBlocks'));
991
-        foreach ($syntax['blocks'] as $name => $block) {
992
-            if ($block['type'] == 'block') {
993
-                continue;
994
-            }
995
-            if (is_array(@$syntax['blocks'][$name]['lookfor'])) {
996
-                usort($syntax['blocks'][$name]['lookfor'], array(&$this, '_sortLookFor'));
997
-            }
998
-        }
999
-        usort($syntax['toplevel'], array(&$this, '_sortLookFor'));
1000
-        $syntax['case'] = $this->_case;
1001
-        $this->_code = <<<CODE
812
+	// {{{ xmltag_Comment_
813
+
814
+	/**
815
+	 * end handler for <comment> element
816
+	 */
817
+	function xmltag_Comment_($xp, $elem)
818
+	{
819
+		$this->_inComment = false;
820
+	}
821
+
822
+	// }}}
823
+	// {{{ xmltag_Region_
824
+
825
+	/**
826
+	 * end handler for <region> element
827
+	 */
828
+	function xmltag_Region_($xp, $elem)
829
+	{
830
+		$this->_element['type'] = 'region';
831
+		$this->_element['order'] = $this->_blockOrder ++;
832
+		$this->_regions[$this->_element['name']] = $this->_element;
833
+	}
834
+
835
+	// }}}
836
+	// {{{ xmltag_Keywords_
837
+
838
+	/**
839
+	 * end handler for <keywords> element
840
+	 */
841
+	function xmltag_Keywords_($xp, $elem)
842
+	{
843
+		$this->_keywords[$this->_element['name']] = $this->_element;
844
+	}
845
+
846
+	// }}}
847
+	// {{{ xmltag_Block_
848
+
849
+	/**
850
+	 * end handler for <block> element
851
+	 */
852
+	function xmltag_Block_($xp, $elem)
853
+	{
854
+		$this->_element['type'] = 'block';
855
+		$this->_element['order'] = $this->_blockOrder ++;
856
+		$this->_blocks[$this->_element['name']] = $this->_element;
857
+	}
858
+
859
+	// }}}
860
+	// {{{ xmltag_Highlight_
861
+
862
+	/**
863
+	 * end handler for <highlight> element
864
+	 */
865
+	function xmltag_Highlight_($xp, $elem)
866
+	{
867
+		$conditions = array();
868
+		$toplevel = array();
869
+		foreach ($this->_blocks as $i => $current) {
870
+			if (!$current['contained'] && !isset($current['onlyin'])) {
871
+				$toplevel[] = $i;
872
+			}
873
+			foreach ((array)@$current['onlyin'] as $region => $lineNo) {
874
+				if (!isset($this->_regions[$region])) {
875
+					$this->_error(TEXT_HIGHLIGHTER_BLOCK_REGION,
876
+					array(
877
+					'block' => $current['name'],
878
+					'region' => $region
879
+					));
880
+				}
881
+			}
882
+		}
883
+		foreach ($this->_regions as $i=>$current) {
884
+			if (!$current['contained'] && !isset($current['onlyin'])) {
885
+				$toplevel[] = $i;
886
+			}
887
+			foreach ((array)@$current['contains']['region'] as $region => $lineNo) {
888
+				if (!isset($this->_regions[$region])) {
889
+					$this->_error(TEXT_HIGHLIGHTER_REGION_REGION,
890
+					array(
891
+					'region1' => $current['name'],
892
+					'region2' => $region
893
+					));
894
+				}
895
+			}
896
+			foreach ((array)@$current['contains']['block'] as $region => $lineNo) {
897
+				if (!isset($this->_blocks[$region])) {
898
+					$this->_error(TEXT_HIGHLIGHTER_REGION_BLOCK,
899
+					array(
900
+					'block' => $current['name'],
901
+					'region' => $region
902
+					));
903
+				}
904
+			}
905
+			foreach ((array)@$current['onlyin'] as $region => $lineNo) {
906
+				if (!isset($this->_regions[$region])) {
907
+					$this->_error(TEXT_HIGHLIGHTER_REGION_REGION,
908
+					array(
909
+					'region1' => $current['name'],
910
+					'region2' => $region
911
+					));
912
+				}
913
+			}
914
+			foreach ($this->_regions as $j => $region) {
915
+				if (isset($region['onlyin'])) {
916
+					$suits = isset($region['onlyin'][$current['name']]);
917
+				} elseif (isset($current['not-contains']['region'][$region['name']])) {
918
+					$suits = false;
919
+				} elseif (isset($current['contains']['region'][$region['name']])) {
920
+					$suits = true;
921
+				} else {
922
+					$suits = @$current['contains-all'] && @!$region['never-contained'];
923
+				}
924
+				if ($suits) {
925
+					$this->_regions[$i]['lookfor'][] = $j;
926
+				}
927
+			}
928
+			foreach ($this->_blocks as $j=>$region) {
929
+				if (isset($region['onlyin'])) {
930
+					$suits = isset($region['onlyin'][$current['name']]);
931
+				} elseif (isset($current['not-contains']['block'][$region['name']])) {
932
+					$suits = false;
933
+				} elseif (isset($current['contains']['block'][$region['name']])) {
934
+					$suits = true;
935
+				} else {
936
+					$suits = @$current['contains-all'] && @!$region['never-contained'];
937
+				}
938
+				if ($suits) {
939
+					$this->_regions[$i]['lookfor'][] = $j;
940
+				}
941
+			}
942
+		}
943
+		foreach ($this->_blocks as $i=>$current) {
944
+			unset ($this->_blocks[$i]['never-contained']);
945
+			unset ($this->_blocks[$i]['contained']);
946
+			unset ($this->_blocks[$i]['contains-all']);
947
+			unset ($this->_blocks[$i]['contains']);
948
+			unset ($this->_blocks[$i]['onlyin']);
949
+			unset ($this->_blocks[$i]['line']);
950
+		}
951
+
952
+		foreach ($this->_regions as $i=>$current) {
953
+			unset ($this->_regions[$i]['never-contained']);
954
+			unset ($this->_regions[$i]['contained']);
955
+			unset ($this->_regions[$i]['contains-all']);
956
+			unset ($this->_regions[$i]['contains']);
957
+			unset ($this->_regions[$i]['onlyin']);
958
+			unset ($this->_regions[$i]['line']);
959
+		}
960
+
961
+		foreach ($this->_keywords as $name => $keyword) {
962
+			if (isset($keyword['ifdef'])) {
963
+				$conditions[$keyword['ifdef']][] = array($name, true);
964
+			}
965
+			if (isset($keyword['ifndef'])) {
966
+				$conditions[$keyword['ifndef']][] = array($name, false);
967
+			}
968
+			unset($this->_keywords[$name]['line']);
969
+			if (!isset($this->_blocks[$keyword['inherits']])) {
970
+				$this->_error(TEXT_HIGHLIGHTER_KEYWORD_INHERITS,
971
+				array(
972
+				'keyword' => $keyword['name'],
973
+				'block' => $keyword['inherits']
974
+				));
975
+			}
976
+			if (isset($keyword['otherwise']) && !isset($this->_blocks[$keyword['otherwise']]) ) {
977
+				$this->_error(TEXT_HIGHLIGHTER_KEYWORD_BLOCK,
978
+				array(
979
+				'keyword' => $keyword['name'],
980
+				'block' => $keyword['inherits']
981
+				));
982
+			}
983
+		}
984
+
985
+		$syntax=array(
986
+		'keywords'   => $this->_keywords,
987
+		'blocks'     => array_merge($this->_blocks, $this->_regions),
988
+		'toplevel'   => $toplevel,
989
+		);
990
+		uasort($syntax['blocks'], array(&$this, '_sortBlocks'));
991
+		foreach ($syntax['blocks'] as $name => $block) {
992
+			if ($block['type'] == 'block') {
993
+				continue;
994
+			}
995
+			if (is_array(@$syntax['blocks'][$name]['lookfor'])) {
996
+				usort($syntax['blocks'][$name]['lookfor'], array(&$this, '_sortLookFor'));
997
+			}
998
+		}
999
+		usort($syntax['toplevel'], array(&$this, '_sortLookFor'));
1000
+		$syntax['case'] = $this->_case;
1001
+		$this->_code = <<<CODE
1002 1002
 <?php
1003 1003
 /**
1004 1004
  * Auto-generated class. {$this->language} syntax highlighting
1005 1005
 CODE;
1006 1006
 
1007
-        if ($this->_comment) {
1008
-            $comment = preg_replace('~^~m',' * ',$this->_comment);
1009
-            $this->_code .= "\n * \n" . $comment;
1010
-        }
1007
+		if ($this->_comment) {
1008
+			$comment = preg_replace('~^~m',' * ',$this->_comment);
1009
+			$this->_code .= "\n * \n" . $comment;
1010
+		}
1011 1011
 
1012
-        $this->_code .= <<<CODE
1012
+		$this->_code .= <<<CODE
1013 1013
 
1014 1014
  *
1015 1015
  * PHP version 4 and 5
@@ -1029,15 +1029,15 @@  discard block
 block discarded – undo
1029 1029
 
1030 1030
 CODE;
1031 1031
 
1032
-        foreach ($this->_authors as $author) {
1033
-            $this->_code .= ' * @author ' . $author['name'];
1034
-            if ($author['email']) {
1035
-                $this->_code .= ' <' . $author['email'] . '>';
1036
-            }
1037
-            $this->_code .= "\n";
1038
-        }
1032
+		foreach ($this->_authors as $author) {
1033
+			$this->_code .= ' * @author ' . $author['name'];
1034
+			if ($author['email']) {
1035
+				$this->_code .= ' <' . $author['email'] . '>';
1036
+			}
1037
+			$this->_code .= "\n";
1038
+		}
1039 1039
 
1040
-        $this->_code .= <<<CODE
1040
+		$this->_code .= <<<CODE
1041 1041
  *
1042 1042
  */
1043 1043
 
@@ -1046,16 +1046,16 @@  discard block
 block discarded – undo
1046 1046
  *
1047 1047
 
1048 1048
 CODE;
1049
-        foreach ($this->_authors as $author) {
1050
-            $this->_code .= ' * @author ' . $author['name'];
1051
-            if ($author['email']) {
1052
-                $this->_code .= ' <' . $author['email']. '>';
1053
-            }
1054
-            $this->_code .= "\n";
1055
-        }
1049
+		foreach ($this->_authors as $author) {
1050
+			$this->_code .= ' * @author ' . $author['name'];
1051
+			if ($author['email']) {
1052
+				$this->_code .= ' <' . $author['email']. '>';
1053
+			}
1054
+			$this->_code .= "\n";
1055
+		}
1056 1056
 
1057 1057
 
1058
-        $this->_code .= <<<CODE
1058
+		$this->_code .= <<<CODE
1059 1059
  * @category   Text
1060 1060
  * @package    Text_Highlighter
1061 1061
  * @copyright  2004-2006 Andrey Demenev
@@ -1067,11 +1067,11 @@  discard block
 block discarded – undo
1067 1067
 {
1068 1068
 
1069 1069
 CODE;
1070
-        $this->_code .= 'var $_language = \'' . strtolower($this->language) . "';\n\n";
1071
-        $array = var_export($syntax, true);
1072
-        $array = trim(preg_replace('~^(\s*)~m','        \1\1',$array));
1073
-        //        \$this->_syntax = $array;
1074
-        $this->_code .= <<<CODE
1070
+		$this->_code .= 'var $_language = \'' . strtolower($this->language) . "';\n\n";
1071
+		$array = var_export($syntax, true);
1072
+		$array = trim(preg_replace('~^(\s*)~m','        \1\1',$array));
1073
+		//        \$this->_syntax = $array;
1074
+		$this->_code .= <<<CODE
1075 1075
 
1076 1076
     /**
1077 1077
      *  Constructor
@@ -1083,154 +1083,154 @@  discard block
 block discarded – undo
1083 1083
     {
1084 1084
 
1085 1085
 CODE;
1086
-        $this->_code .= <<<CODE
1086
+		$this->_code .= <<<CODE
1087 1087
 
1088 1088
         \$this->_options = \$options;
1089 1089
 CODE;
1090
-        $states = array();
1091
-        $i = 0;
1092
-        foreach ($syntax['blocks'] as $name => $block) {
1093
-            if ($block['type'] == 'region') {
1094
-                $states[$name] = $i++;
1095
-            }
1096
-        }
1097
-        $regs = array();
1098
-        $counts = array();
1099
-        $delim = array();
1100
-        $inner = array();
1101
-        $end = array();
1102
-        $stat = array();
1103
-        $keywords = array();
1104
-        $parts = array();
1105
-        $kwmap = array();
1106
-        $subst = array();
1107
-        $re = array();
1108
-        $ce = array();
1109
-        $rd = array();
1110
-        $in = array();
1111
-        $st = array();
1112
-        $kw = array();
1113
-        $sb = array();
1114
-        foreach ($syntax['toplevel'] as $name) {
1115
-            $block = $syntax['blocks'][$name];
1116
-            if ($block['type'] == 'block') {
1117
-                $kwm = array();
1118
-                $re[] = '(' . $block['match'] . ')';
1119
-                $ce[] = $this->_countSubpatterns($block['match']);
1120
-                $rd[] = '';
1121
-                $sb[] = false;;
1122
-                $st[] = -1;
1123
-                foreach ($syntax['keywords'] as $kwname => $kwgroup) {
1124
-                    if ($kwgroup['inherits'] != $name) {
1125
-                        continue;
1126
-                    }
1127
-                    $gre = implode('|', array_keys($kwgroup['match']));
1128
-                    if (!$kwgroup['case']) {
1129
-                        $gre = '(?i)' . $gre;
1130
-                    }
1131
-                    $kwm[$kwname][] =  $gre;
1132
-                    $kwmap[$kwname] = $kwgroup['innerGroup'];
1133
-                }
1134
-                foreach ($kwm as $g => $ma) {
1135
-                    $kwm[$g] = '/^(' . implode(')|(', $ma) . ')$/';
1136
-                }
1137
-                $kw[] = $kwm;
1138
-            } else {
1139
-                $kw[] = -1;
1140
-                $re[] = '(' . $block['start'] . ')';
1141
-                $ce[] = $this->_countSubpatterns($block['start']);
1142
-                $rd[] = $block['delimGroup'];
1143
-                $st[] = $states[$name];
1144
-                $sb[] = $block['remember'];
1145
-            }
1146
-            $in[] = $block['innerGroup'];
1147
-        }
1148
-        $re = implode('|', $re);
1149
-        $regs[-1] = '/' . $re . '/';
1150
-        $counts[-1] = $ce;
1151
-        $delim[-1] = $rd;
1152
-        $inner[-1] = $in;
1153
-        $stat[-1] = $st;
1154
-        $keywords[-1] = $kw;
1155
-        $subst[-1] = $sb;
1156
-
1157
-        foreach ($syntax['blocks'] as $ablock) {
1158
-            if ($ablock['type'] != 'region') {
1159
-                continue;
1160
-            }
1161
-            $end[] = '/' . $ablock['end'] . '/';
1162
-            $re = array();
1163
-            $ce = array();
1164
-            $rd = array();
1165
-            $in = array();
1166
-            $st = array();
1167
-            $kw = array();
1168
-            $pc = array();
1169
-            $sb = array();
1170
-            foreach ((array)@$ablock['lookfor'] as $name) {
1171
-                $block = $syntax['blocks'][$name];
1172
-                if (isset($block['partClass'])) {
1173
-                    $pc[] = $block['partClass'];
1174
-                } else {
1175
-                    $pc[] = null;
1176
-                }
1177
-                if ($block['type'] == 'block') {
1178
-                    $kwm = array();;
1179
-                    $re[] = '(' . $block['match'] . ')';
1180
-                    $ce[] = $this->_countSubpatterns($block['match']);
1181
-                    $rd[] = '';
1182
-                    $sb[] = false;
1183
-                    $st[] = -1;
1184
-                    foreach ($syntax['keywords'] as $kwname => $kwgroup) {
1185
-                        if ($kwgroup['inherits'] != $name) {
1186
-                            continue;
1187
-                        }
1188
-                        $gre = implode('|', array_keys($kwgroup['match']));
1189
-                        if (!$kwgroup['case']) {
1190
-                            $gre = '(?i)' . $gre;
1191
-                        }
1192
-                        $kwm[$kwname][] =  $gre;
1193
-                        $kwmap[$kwname] = $kwgroup['innerGroup'];
1194
-                    }
1195
-                    foreach ($kwm as $g => $ma) {
1196
-                        $kwm[$g] = '/^(' . implode(')|(', $ma) . ')$/';
1197
-                    }
1198
-                    $kw[] = $kwm;
1199
-                } else {
1200
-                    $sb[] = $block['remember'];
1201
-                    $kw[] = -1;
1202
-                    $re[] = '(' . $block['start'] . ')';
1203
-                    $ce[] = $this->_countSubpatterns($block['start']);
1204
-                    $rd[] = $block['delimGroup'];
1205
-                    $st[] = $states[$name];
1206
-                }
1207
-                $in[] = $block['innerGroup'];
1208
-            }
1209
-            $re = implode('|', $re);
1210
-            $regs[] = '/' . $re . '/';
1211
-            $counts[] = $ce;
1212
-            $delim[] = $rd;
1213
-            $inner[] = $in;
1214
-            $stat[] = $st;
1215
-            $keywords[] = $kw;
1216
-            $parts[] = $pc;
1217
-            $subst[] = $sb;
1218
-        }
1219
-
1220
-
1221
-        $this->_code .= "\n        \$this->_regs = " . $this->_exportArray($regs);
1222
-        $this->_code .= ";\n        \$this->_counts = " .$this->_exportArray($counts);
1223
-        $this->_code .= ";\n        \$this->_delim = " .$this->_exportArray($delim);
1224
-        $this->_code .= ";\n        \$this->_inner = " .$this->_exportArray($inner);
1225
-        $this->_code .= ";\n        \$this->_end = " .$this->_exportArray($end);
1226
-        $this->_code .= ";\n        \$this->_states = " .$this->_exportArray($stat);
1227
-        $this->_code .= ";\n        \$this->_keywords = " .$this->_exportArray($keywords);
1228
-        $this->_code .= ";\n        \$this->_parts = " .$this->_exportArray($parts);
1229
-        $this->_code .= ";\n        \$this->_subst = " .$this->_exportArray($subst);
1230
-        $this->_code .= ";\n        \$this->_conditions = " .$this->_exportArray($conditions);
1231
-        $this->_code .= ";\n        \$this->_kwmap = " .$this->_exportArray($kwmap);
1232
-        $this->_code .= ";\n        \$this->_defClass = '" .$this->_defClass . '\'';
1233
-        $this->_code .= <<<CODE
1090
+		$states = array();
1091
+		$i = 0;
1092
+		foreach ($syntax['blocks'] as $name => $block) {
1093
+			if ($block['type'] == 'region') {
1094
+				$states[$name] = $i++;
1095
+			}
1096
+		}
1097
+		$regs = array();
1098
+		$counts = array();
1099
+		$delim = array();
1100
+		$inner = array();
1101
+		$end = array();
1102
+		$stat = array();
1103
+		$keywords = array();
1104
+		$parts = array();
1105
+		$kwmap = array();
1106
+		$subst = array();
1107
+		$re = array();
1108
+		$ce = array();
1109
+		$rd = array();
1110
+		$in = array();
1111
+		$st = array();
1112
+		$kw = array();
1113
+		$sb = array();
1114
+		foreach ($syntax['toplevel'] as $name) {
1115
+			$block = $syntax['blocks'][$name];
1116
+			if ($block['type'] == 'block') {
1117
+				$kwm = array();
1118
+				$re[] = '(' . $block['match'] . ')';
1119
+				$ce[] = $this->_countSubpatterns($block['match']);
1120
+				$rd[] = '';
1121
+				$sb[] = false;;
1122
+				$st[] = -1;
1123
+				foreach ($syntax['keywords'] as $kwname => $kwgroup) {
1124
+					if ($kwgroup['inherits'] != $name) {
1125
+						continue;
1126
+					}
1127
+					$gre = implode('|', array_keys($kwgroup['match']));
1128
+					if (!$kwgroup['case']) {
1129
+						$gre = '(?i)' . $gre;
1130
+					}
1131
+					$kwm[$kwname][] =  $gre;
1132
+					$kwmap[$kwname] = $kwgroup['innerGroup'];
1133
+				}
1134
+				foreach ($kwm as $g => $ma) {
1135
+					$kwm[$g] = '/^(' . implode(')|(', $ma) . ')$/';
1136
+				}
1137
+				$kw[] = $kwm;
1138
+			} else {
1139
+				$kw[] = -1;
1140
+				$re[] = '(' . $block['start'] . ')';
1141
+				$ce[] = $this->_countSubpatterns($block['start']);
1142
+				$rd[] = $block['delimGroup'];
1143
+				$st[] = $states[$name];
1144
+				$sb[] = $block['remember'];
1145
+			}
1146
+			$in[] = $block['innerGroup'];
1147
+		}
1148
+		$re = implode('|', $re);
1149
+		$regs[-1] = '/' . $re . '/';
1150
+		$counts[-1] = $ce;
1151
+		$delim[-1] = $rd;
1152
+		$inner[-1] = $in;
1153
+		$stat[-1] = $st;
1154
+		$keywords[-1] = $kw;
1155
+		$subst[-1] = $sb;
1156
+
1157
+		foreach ($syntax['blocks'] as $ablock) {
1158
+			if ($ablock['type'] != 'region') {
1159
+				continue;
1160
+			}
1161
+			$end[] = '/' . $ablock['end'] . '/';
1162
+			$re = array();
1163
+			$ce = array();
1164
+			$rd = array();
1165
+			$in = array();
1166
+			$st = array();
1167
+			$kw = array();
1168
+			$pc = array();
1169
+			$sb = array();
1170
+			foreach ((array)@$ablock['lookfor'] as $name) {
1171
+				$block = $syntax['blocks'][$name];
1172
+				if (isset($block['partClass'])) {
1173
+					$pc[] = $block['partClass'];
1174
+				} else {
1175
+					$pc[] = null;
1176
+				}
1177
+				if ($block['type'] == 'block') {
1178
+					$kwm = array();;
1179
+					$re[] = '(' . $block['match'] . ')';
1180
+					$ce[] = $this->_countSubpatterns($block['match']);
1181
+					$rd[] = '';
1182
+					$sb[] = false;
1183
+					$st[] = -1;
1184
+					foreach ($syntax['keywords'] as $kwname => $kwgroup) {
1185
+						if ($kwgroup['inherits'] != $name) {
1186
+							continue;
1187
+						}
1188
+						$gre = implode('|', array_keys($kwgroup['match']));
1189
+						if (!$kwgroup['case']) {
1190
+							$gre = '(?i)' . $gre;
1191
+						}
1192
+						$kwm[$kwname][] =  $gre;
1193
+						$kwmap[$kwname] = $kwgroup['innerGroup'];
1194
+					}
1195
+					foreach ($kwm as $g => $ma) {
1196
+						$kwm[$g] = '/^(' . implode(')|(', $ma) . ')$/';
1197
+					}
1198
+					$kw[] = $kwm;
1199
+				} else {
1200
+					$sb[] = $block['remember'];
1201
+					$kw[] = -1;
1202
+					$re[] = '(' . $block['start'] . ')';
1203
+					$ce[] = $this->_countSubpatterns($block['start']);
1204
+					$rd[] = $block['delimGroup'];
1205
+					$st[] = $states[$name];
1206
+				}
1207
+				$in[] = $block['innerGroup'];
1208
+			}
1209
+			$re = implode('|', $re);
1210
+			$regs[] = '/' . $re . '/';
1211
+			$counts[] = $ce;
1212
+			$delim[] = $rd;
1213
+			$inner[] = $in;
1214
+			$stat[] = $st;
1215
+			$keywords[] = $kw;
1216
+			$parts[] = $pc;
1217
+			$subst[] = $sb;
1218
+		}
1219
+
1220
+
1221
+		$this->_code .= "\n        \$this->_regs = " . $this->_exportArray($regs);
1222
+		$this->_code .= ";\n        \$this->_counts = " .$this->_exportArray($counts);
1223
+		$this->_code .= ";\n        \$this->_delim = " .$this->_exportArray($delim);
1224
+		$this->_code .= ";\n        \$this->_inner = " .$this->_exportArray($inner);
1225
+		$this->_code .= ";\n        \$this->_end = " .$this->_exportArray($end);
1226
+		$this->_code .= ";\n        \$this->_states = " .$this->_exportArray($stat);
1227
+		$this->_code .= ";\n        \$this->_keywords = " .$this->_exportArray($keywords);
1228
+		$this->_code .= ";\n        \$this->_parts = " .$this->_exportArray($parts);
1229
+		$this->_code .= ";\n        \$this->_subst = " .$this->_exportArray($subst);
1230
+		$this->_code .= ";\n        \$this->_conditions = " .$this->_exportArray($conditions);
1231
+		$this->_code .= ";\n        \$this->_kwmap = " .$this->_exportArray($kwmap);
1232
+		$this->_code .= ";\n        \$this->_defClass = '" .$this->_defClass . '\'';
1233
+		$this->_code .= <<<CODE
1234 1234
 ;
1235 1235
         \$this->_checkDefines();
1236 1236
     }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -48 removed lines patch added patch discarded remove patch
@@ -27,18 +27,18 @@  discard block
 block discarded – undo
27 27
 
28 28
 // {{{ error codes
29 29
 
30
-define ('TEXT_HIGHLIGHTER_EMPTY_RE',          1);
31
-define ('TEXT_HIGHLIGHTER_INVALID_RE',        2);
32
-define ('TEXT_HIGHLIGHTER_EMPTY_OR_MISSING',  3);
33
-define ('TEXT_HIGHLIGHTER_EMPTY',             4);
34
-define ('TEXT_HIGHLIGHTER_REGION_REGION',     5);
35
-define ('TEXT_HIGHLIGHTER_REGION_BLOCK',      6);
36
-define ('TEXT_HIGHLIGHTER_BLOCK_REGION',      7);
37
-define ('TEXT_HIGHLIGHTER_KEYWORD_BLOCK',     8);
38
-define ('TEXT_HIGHLIGHTER_KEYWORD_INHERITS',  9);
39
-define ('TEXT_HIGHLIGHTER_PARSE',            10);
40
-define ('TEXT_HIGHLIGHTER_FILE_WRITE',       11);
41
-define ('TEXT_HIGHLIGHTER_FILE_READ',        12);
30
+define('TEXT_HIGHLIGHTER_EMPTY_RE', 1);
31
+define('TEXT_HIGHLIGHTER_INVALID_RE', 2);
32
+define('TEXT_HIGHLIGHTER_EMPTY_OR_MISSING', 3);
33
+define('TEXT_HIGHLIGHTER_EMPTY', 4);
34
+define('TEXT_HIGHLIGHTER_REGION_REGION', 5);
35
+define('TEXT_HIGHLIGHTER_REGION_BLOCK', 6);
36
+define('TEXT_HIGHLIGHTER_BLOCK_REGION', 7);
37
+define('TEXT_HIGHLIGHTER_KEYWORD_BLOCK', 8);
38
+define('TEXT_HIGHLIGHTER_KEYWORD_INHERITS', 9);
39
+define('TEXT_HIGHLIGHTER_PARSE', 10);
40
+define('TEXT_HIGHLIGHTER_FILE_WRITE', 11);
41
+define('TEXT_HIGHLIGHTER_FILE_READ', 12);
42 42
 // }}}
43 43
 
44 44
 /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     */
240 240
     function _declareErrorMessages()
241 241
     {
242
-        $this->_templates = array (
242
+        $this->_templates = array(
243 243
         TEXT_HIGHLIGHTER_EMPTY_RE => 'Empty regular expression',
244 244
         TEXT_HIGHLIGHTER_INVALID_RE => 'Invalid regular expression : %s',
245 245
         TEXT_HIGHLIGHTER_EMPTY_OR_MISSING => 'Empty or missing %s',
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         $this->_inComment  = false;
298 298
         $this->_authors    = array();
299 299
         $this->_blockOrder = 0;
300
-        $this->_errors   = array();
300
+        $this->_errors = array();
301 301
 
302 302
         $ret = $this->parse();
303 303
         if (PEAR::isError($ret)) {
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             $this->_error(TEXT_HIGHLIGHTER_FILE_WRITE, array('outfile'=>$filename));
343 343
             return false;
344 344
         }
345
-        fwrite ($f, $this->_code);
345
+        fwrite($f, $this->_code);
346 346
         fclose($f);
347 347
         return true;
348 348
     }
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
         if ($php_errormsg) {
431 431
             $this->_error(TEXT_HIGHLIGHTER_INVALID_RE, $php_errormsg);
432 432
         }
433
-        preg_match ('#^/(.+)/(.*)$#', $text, $m);
433
+        preg_match('#^/(.+)/(.*)$#', $text, $m);
434 434
         if (@$m[2]) {
435 435
             $text = '(?' . $m[2] . ')' . $m[1];
436 436
         } else {
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
     function _exportArray($array)
453 453
     {
454 454
         $array = var_export($array, true);
455
-        return trim(preg_replace('~^(\s*)~m','        \1\1',$array));
455
+        return trim(preg_replace('~^(\s*)~m', '        \1\1', $array));
456 456
     }
457 457
 
458 458
     // }}}
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
     function _countSubpatterns($re)
466 466
     {
467 467
         preg_match_all('/' . $re . '/', '', $m);
468
-        return count($m)-1;
468
+        return count($m) - 1;
469 469
     }
470 470
 
471 471
     // }}}
@@ -515,8 +515,7 @@  discard block
 block discarded – undo
515 515
         }
516 516
         $this->_element['innerGroup'] = $attribs['innerGroup'];
517 517
         $this->_element['delimGroup'] = isset($attribs['delimGroup']) ?
518
-        $attribs['delimGroup'] :
519
-        $attribs['innerGroup'];
518
+        $attribs['delimGroup'] : $attribs['innerGroup'];
520 519
         $this->_element['start'] = $this->_makeRE(@$attribs['start'], $this->_element['case']);
521 520
         $this->_element['end'] = $this->_makeRE(@$attribs['end'], $this->_element['case']);
522 521
         $this->_element['contained'] = @$attribs['contained'] == 'yes';
@@ -738,7 +737,7 @@  discard block
 block discarded – undo
738 737
         }
739 738
         $this->_authors[] = array(
740 739
         'name'  => @$attribs['name'],
741
-        'email' => (string)@$attribs['email']
740
+        'email' => (string) @$attribs['email']
742 741
         );
743 742
     }
744 743
 
@@ -828,7 +827,7 @@  discard block
 block discarded – undo
828 827
     function xmltag_Region_($xp, $elem)
829 828
     {
830 829
         $this->_element['type'] = 'region';
831
-        $this->_element['order'] = $this->_blockOrder ++;
830
+        $this->_element['order'] = $this->_blockOrder++;
832 831
         $this->_regions[$this->_element['name']] = $this->_element;
833 832
     }
834 833
 
@@ -852,7 +851,7 @@  discard block
 block discarded – undo
852 851
     function xmltag_Block_($xp, $elem)
853 852
     {
854 853
         $this->_element['type'] = 'block';
855
-        $this->_element['order'] = $this->_blockOrder ++;
854
+        $this->_element['order'] = $this->_blockOrder++;
856 855
         $this->_blocks[$this->_element['name']] = $this->_element;
857 856
     }
858 857
 
@@ -870,7 +869,7 @@  discard block
 block discarded – undo
870 869
             if (!$current['contained'] && !isset($current['onlyin'])) {
871 870
                 $toplevel[] = $i;
872 871
             }
873
-            foreach ((array)@$current['onlyin'] as $region => $lineNo) {
872
+            foreach ((array) @$current['onlyin'] as $region => $lineNo) {
874 873
                 if (!isset($this->_regions[$region])) {
875 874
                     $this->_error(TEXT_HIGHLIGHTER_BLOCK_REGION,
876 875
                     array(
@@ -884,7 +883,7 @@  discard block
 block discarded – undo
884 883
             if (!$current['contained'] && !isset($current['onlyin'])) {
885 884
                 $toplevel[] = $i;
886 885
             }
887
-            foreach ((array)@$current['contains']['region'] as $region => $lineNo) {
886
+            foreach ((array) @$current['contains']['region'] as $region => $lineNo) {
888 887
                 if (!isset($this->_regions[$region])) {
889 888
                     $this->_error(TEXT_HIGHLIGHTER_REGION_REGION,
890 889
                     array(
@@ -893,7 +892,7 @@  discard block
 block discarded – undo
893 892
                     ));
894 893
                 }
895 894
             }
896
-            foreach ((array)@$current['contains']['block'] as $region => $lineNo) {
895
+            foreach ((array) @$current['contains']['block'] as $region => $lineNo) {
897 896
                 if (!isset($this->_blocks[$region])) {
898 897
                     $this->_error(TEXT_HIGHLIGHTER_REGION_BLOCK,
899 898
                     array(
@@ -902,7 +901,7 @@  discard block
 block discarded – undo
902 901
                     ));
903 902
                 }
904 903
             }
905
-            foreach ((array)@$current['onlyin'] as $region => $lineNo) {
904
+            foreach ((array) @$current['onlyin'] as $region => $lineNo) {
906 905
                 if (!isset($this->_regions[$region])) {
907 906
                     $this->_error(TEXT_HIGHLIGHTER_REGION_REGION,
908 907
                     array(
@@ -973,7 +972,7 @@  discard block
 block discarded – undo
973 972
                 'block' => $keyword['inherits']
974 973
                 ));
975 974
             }
976
-            if (isset($keyword['otherwise']) && !isset($this->_blocks[$keyword['otherwise']]) ) {
975
+            if (isset($keyword['otherwise']) && !isset($this->_blocks[$keyword['otherwise']])) {
977 976
                 $this->_error(TEXT_HIGHLIGHTER_KEYWORD_BLOCK,
978 977
                 array(
979 978
                 'keyword' => $keyword['name'],
@@ -982,7 +981,7 @@  discard block
 block discarded – undo
982 981
             }
983 982
         }
984 983
 
985
-        $syntax=array(
984
+        $syntax = array(
986 985
         'keywords'   => $this->_keywords,
987 986
         'blocks'     => array_merge($this->_blocks, $this->_regions),
988 987
         'toplevel'   => $toplevel,
@@ -1005,7 +1004,7 @@  discard block
 block discarded – undo
1005 1004
 CODE;
1006 1005
 
1007 1006
         if ($this->_comment) {
1008
-            $comment = preg_replace('~^~m',' * ',$this->_comment);
1007
+            $comment = preg_replace('~^~m', ' * ', $this->_comment);
1009 1008
             $this->_code .= "\n * \n" . $comment;
1010 1009
         }
1011 1010
 
@@ -1049,7 +1048,7 @@  discard block
 block discarded – undo
1049 1048
         foreach ($this->_authors as $author) {
1050 1049
             $this->_code .= ' * @author ' . $author['name'];
1051 1050
             if ($author['email']) {
1052
-                $this->_code .= ' <' . $author['email']. '>';
1051
+                $this->_code .= ' <' . $author['email'] . '>';
1053 1052
             }
1054 1053
             $this->_code .= "\n";
1055 1054
         }
@@ -1069,7 +1068,7 @@  discard block
 block discarded – undo
1069 1068
 CODE;
1070 1069
         $this->_code .= 'var $_language = \'' . strtolower($this->language) . "';\n\n";
1071 1070
         $array = var_export($syntax, true);
1072
-        $array = trim(preg_replace('~^(\s*)~m','        \1\1',$array));
1071
+        $array = trim(preg_replace('~^(\s*)~m', '        \1\1', $array));
1073 1072
         //        \$this->_syntax = $array;
1074 1073
         $this->_code .= <<<CODE
1075 1074
 
@@ -1118,7 +1117,7 @@  discard block
 block discarded – undo
1118 1117
                 $re[] = '(' . $block['match'] . ')';
1119 1118
                 $ce[] = $this->_countSubpatterns($block['match']);
1120 1119
                 $rd[] = '';
1121
-                $sb[] = false;;
1120
+                $sb[] = false; ;
1122 1121
                 $st[] = -1;
1123 1122
                 foreach ($syntax['keywords'] as $kwname => $kwgroup) {
1124 1123
                     if ($kwgroup['inherits'] != $name) {
@@ -1128,7 +1127,7 @@  discard block
 block discarded – undo
1128 1127
                     if (!$kwgroup['case']) {
1129 1128
                         $gre = '(?i)' . $gre;
1130 1129
                     }
1131
-                    $kwm[$kwname][] =  $gre;
1130
+                    $kwm[$kwname][] = $gre;
1132 1131
                     $kwmap[$kwname] = $kwgroup['innerGroup'];
1133 1132
                 }
1134 1133
                 foreach ($kwm as $g => $ma) {
@@ -1167,7 +1166,7 @@  discard block
 block discarded – undo
1167 1166
             $kw = array();
1168 1167
             $pc = array();
1169 1168
             $sb = array();
1170
-            foreach ((array)@$ablock['lookfor'] as $name) {
1169
+            foreach ((array) @$ablock['lookfor'] as $name) {
1171 1170
                 $block = $syntax['blocks'][$name];
1172 1171
                 if (isset($block['partClass'])) {
1173 1172
                     $pc[] = $block['partClass'];
@@ -1175,7 +1174,7 @@  discard block
 block discarded – undo
1175 1174
                     $pc[] = null;
1176 1175
                 }
1177 1176
                 if ($block['type'] == 'block') {
1178
-                    $kwm = array();;
1177
+                    $kwm = array(); ;
1179 1178
                     $re[] = '(' . $block['match'] . ')';
1180 1179
                     $ce[] = $this->_countSubpatterns($block['match']);
1181 1180
                     $rd[] = '';
@@ -1189,7 +1188,7 @@  discard block
 block discarded – undo
1189 1188
                         if (!$kwgroup['case']) {
1190 1189
                             $gre = '(?i)' . $gre;
1191 1190
                         }
1192
-                        $kwm[$kwname][] =  $gre;
1191
+                        $kwm[$kwname][] = $gre;
1193 1192
                         $kwmap[$kwname] = $kwgroup['innerGroup'];
1194 1193
                     }
1195 1194
                     foreach ($kwm as $g => $ma) {
@@ -1219,17 +1218,17 @@  discard block
 block discarded – undo
1219 1218
 
1220 1219
 
1221 1220
         $this->_code .= "\n        \$this->_regs = " . $this->_exportArray($regs);
1222
-        $this->_code .= ";\n        \$this->_counts = " .$this->_exportArray($counts);
1223
-        $this->_code .= ";\n        \$this->_delim = " .$this->_exportArray($delim);
1224
-        $this->_code .= ";\n        \$this->_inner = " .$this->_exportArray($inner);
1225
-        $this->_code .= ";\n        \$this->_end = " .$this->_exportArray($end);
1226
-        $this->_code .= ";\n        \$this->_states = " .$this->_exportArray($stat);
1227
-        $this->_code .= ";\n        \$this->_keywords = " .$this->_exportArray($keywords);
1228
-        $this->_code .= ";\n        \$this->_parts = " .$this->_exportArray($parts);
1229
-        $this->_code .= ";\n        \$this->_subst = " .$this->_exportArray($subst);
1230
-        $this->_code .= ";\n        \$this->_conditions = " .$this->_exportArray($conditions);
1231
-        $this->_code .= ";\n        \$this->_kwmap = " .$this->_exportArray($kwmap);
1232
-        $this->_code .= ";\n        \$this->_defClass = '" .$this->_defClass . '\'';
1221
+        $this->_code .= ";\n        \$this->_counts = " . $this->_exportArray($counts);
1222
+        $this->_code .= ";\n        \$this->_delim = " . $this->_exportArray($delim);
1223
+        $this->_code .= ";\n        \$this->_inner = " . $this->_exportArray($inner);
1224
+        $this->_code .= ";\n        \$this->_end = " . $this->_exportArray($end);
1225
+        $this->_code .= ";\n        \$this->_states = " . $this->_exportArray($stat);
1226
+        $this->_code .= ";\n        \$this->_keywords = " . $this->_exportArray($keywords);
1227
+        $this->_code .= ";\n        \$this->_parts = " . $this->_exportArray($parts);
1228
+        $this->_code .= ";\n        \$this->_subst = " . $this->_exportArray($subst);
1229
+        $this->_code .= ";\n        \$this->_conditions = " . $this->_exportArray($conditions);
1230
+        $this->_code .= ";\n        \$this->_kwmap = " . $this->_exportArray($kwmap);
1231
+        $this->_code .= ";\n        \$this->_defClass = '" . $this->_defClass . '\'';
1233 1232
         $this->_code .= <<<CODE
1234 1233
 ;
1235 1234
         \$this->_checkDefines();
Please login to merge, or discard this patch.
framework/3rdParty/TextHighlighter/Text/Highlighter/Renderer.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,6 @@  discard block
 block discarded – undo
68 68
      *
69 69
      * @access public
70 70
      *
71
-     * @param  array $options  Rendering options. Renderer-specific.
72 71
      */
73 72
     function reset()
74 73
     {
@@ -130,6 +129,7 @@  discard block
 block discarded – undo
130 129
      * Set current language
131 130
      *
132 131
      * @abstract
132
+     * @param string $lang
133 133
      * @return void
134 134
      * @access public
135 135
      *
Please login to merge, or discard this patch.
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -35,109 +35,109 @@
 block discarded – undo
35 35
 
36 36
 class Text_Highlighter_Renderer
37 37
 {
38
-    /**
39
-     * Renderer options
40
-     *
41
-     * @var array
42
-     * @access protected
43
-     */
44
-    public $_options = array();
38
+	/**
39
+	 * Renderer options
40
+	 *
41
+	 * @var array
42
+	 * @access protected
43
+	 */
44
+	public $_options = array();
45 45
 
46
-    /**
47
-     * Current language
48
-     *
49
-     * @var string
50
-     * @access protected
51
-     */
52
-    public $_language = '';
46
+	/**
47
+	 * Current language
48
+	 *
49
+	 * @var string
50
+	 * @access protected
51
+	 */
52
+	public $_language = '';
53 53
 
54
-    /**
55
-     * Constructor
56
-     *
57
-     * @access public
58
-     *
59
-     * @param  array $options  Rendering options. Renderer-specific.
60
-     */
61
-    function __construct($options = array())
62
-    {
63
-        $this->_options = $options;
64
-    }
54
+	/**
55
+	 * Constructor
56
+	 *
57
+	 * @access public
58
+	 *
59
+	 * @param  array $options  Rendering options. Renderer-specific.
60
+	 */
61
+	function __construct($options = array())
62
+	{
63
+		$this->_options = $options;
64
+	}
65 65
 
66
-    /**
67
-     * Resets renderer state
68
-     *
69
-     * @access public
70
-     *
71
-     * @param  array $options  Rendering options. Renderer-specific.
72
-     */
73
-    function reset()
74
-    {
75
-        return;
76
-    }
66
+	/**
67
+	 * Resets renderer state
68
+	 *
69
+	 * @access public
70
+	 *
71
+	 * @param  array $options  Rendering options. Renderer-specific.
72
+	 */
73
+	function reset()
74
+	{
75
+		return;
76
+	}
77 77
 
78
-    /**
79
-     * Preprocesses code
80
-     *
81
-     * @access public
82
-     *
83
-     * @param  string $str Code to preprocess
84
-     * @return string Preprocessed code
85
-     */
86
-    function preprocess($str)
87
-    {
88
-        return $str;
89
-    }
78
+	/**
79
+	 * Preprocesses code
80
+	 *
81
+	 * @access public
82
+	 *
83
+	 * @param  string $str Code to preprocess
84
+	 * @return string Preprocessed code
85
+	 */
86
+	function preprocess($str)
87
+	{
88
+		return $str;
89
+	}
90 90
 
91
-    /**
92
-     * Accepts next token
93
-     *
94
-     * @abstract
95
-     * @access public
96
-     *
97
-     * @param  string $class   Token class
98
-     * @param  string $content Token content
99
-     */
100
-    function acceptToken($class, $content)
101
-    {
102
-        return;
103
-    }
91
+	/**
92
+	 * Accepts next token
93
+	 *
94
+	 * @abstract
95
+	 * @access public
96
+	 *
97
+	 * @param  string $class   Token class
98
+	 * @param  string $content Token content
99
+	 */
100
+	function acceptToken($class, $content)
101
+	{
102
+		return;
103
+	}
104 104
 
105
-    /**
106
-     * Signals that no more tokens are available
107
-     *
108
-     * @access public
109
-     *
110
-     */
111
-    function finalize()
112
-    {
113
-        return;
114
-    }
105
+	/**
106
+	 * Signals that no more tokens are available
107
+	 *
108
+	 * @access public
109
+	 *
110
+	 */
111
+	function finalize()
112
+	{
113
+		return;
114
+	}
115 115
 
116
-    /**
117
-     * Get generated output
118
-     *
119
-     * @abstract
120
-     * @return mixed Renderer-specific
121
-     * @access public
122
-     *
123
-     */
124
-    function getOutput()
125
-    {
126
-        return;
127
-    }
116
+	/**
117
+	 * Get generated output
118
+	 *
119
+	 * @abstract
120
+	 * @return mixed Renderer-specific
121
+	 * @access public
122
+	 *
123
+	 */
124
+	function getOutput()
125
+	{
126
+		return;
127
+	}
128 128
 
129
-    /**
130
-     * Set current language
131
-     *
132
-     * @abstract
133
-     * @return void
134
-     * @access public
135
-     *
136
-     */
137
-    function setCurrentLanguage($lang)
138
-    {
139
-        $this->_language = $lang;
140
-    }
129
+	/**
130
+	 * Set current language
131
+	 *
132
+	 * @abstract
133
+	 * @return void
134
+	 * @access public
135
+	 *
136
+	 */
137
+	function setCurrentLanguage($lang)
138
+	{
139
+		$this->_language = $lang;
140
+	}
141 141
 
142 142
 }
143 143
 
Please login to merge, or discard this patch.
framework/3rdParty/WsdlGen/WsdlMessage.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,6 @@
 block discarded – undo
59 59
 
60 60
 	/**
61 61
 	 * Return the message as a DOM element
62
-	 * @param 		DOMDocument		$wsdl		The wsdl document the messages will be children of
63 62
 	 */
64 63
 	public function getMessageElement(DOMDocument $dom)
65 64
 	{
Please login to merge, or discard this patch.
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WsdlMessage file.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the BSD License.
7
- *
8
- * Copyright(c) 2005 by Marcus Nyeholt. All rights reserved.
9
- *
10
- * To contact the author write to {@link mailto:[email protected] Marcus Nyeholt}
11
- * This file is part of the PRADO framework from {@link http://www.xisc.com}
12
- *
13
- * @author Marcus Nyeholt		<[email protected]>
14
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
- * @package System.Web.Services.SOAP
16
- */
3
+	 * WsdlMessage file.
4
+	 *
5
+	 * This program is free software; you can redistribute it and/or modify
6
+	 * it under the terms of the BSD License.
7
+	 *
8
+	 * Copyright(c) 2005 by Marcus Nyeholt. All rights reserved.
9
+	 *
10
+	 * To contact the author write to {@link mailto:[email protected] Marcus Nyeholt}
11
+	 * This file is part of the PRADO framework from {@link http://www.xisc.com}
12
+	 *
13
+	 * @author Marcus Nyeholt		<[email protected]>
14
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
+	 * @package System.Web.Services.SOAP
16
+	 */
17 17
 
18 18
 /**
19 19
  * Represents a WSDL message. This is bound to the portTypes
Please login to merge, or discard this patch.
framework/Caching/TCache.php 3 patches
Doc Comments   +16 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,6 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
 	/**
100 100
 	 * @param string a unique prefix for the keys of cached values
101
+	 * @param string $value
101 102
 	 */
102 103
 	public function setKeyPrefix($value)
103 104
 	{
@@ -106,7 +107,7 @@  discard block
 block discarded – undo
106 107
 
107 108
 	/**
108 109
 	 * @param string a key identifying a value to be cached
109
-	 * @return sring a key generated from the provided key which ensures the uniqueness across applications
110
+	 * @return string a key generated from the provided key which ensures the uniqueness across applications
110 111
 	 */
111 112
 	protected function generateUniqueKey($key)
112 113
 	{
@@ -160,6 +161,8 @@  discard block
 block discarded – undo
160 161
 	 * @param mixed the value to be cached
161 162
 	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
162 163
 	 * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid.
164
+	 * @param string $id
165
+	 * @param string $value
163 166
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
164 167
 	 */
165 168
 	public function add($id,$value,$expire=0,$dependency=null)
@@ -198,6 +201,7 @@  discard block
 block discarded – undo
198 201
 	 * in {@link get()} already. So only the implementation of data retrieval
199 202
 	 * is needed.
200 203
 	 * @param string a unique key identifying the cached value
204
+	 * @param string $key
201 205
 	 * @return string the value stored in cache, false if the value is not in the cache or expired.
202 206
 	 */
203 207
 	abstract protected function getValue($key);
@@ -212,6 +216,8 @@  discard block
 block discarded – undo
212 216
 	 * @param string the key identifying the value to be cached
213 217
 	 * @param string the value to be cached
214 218
 	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
219
+	 * @param string $key
220
+	 * @param integer $expire
215 221
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
216 222
 	 */
217 223
 	abstract protected function setValue($key,$value,$expire);
@@ -226,6 +232,8 @@  discard block
 block discarded – undo
226 232
 	 * @param string the key identifying the value to be cached
227 233
 	 * @param string the value to be cached
228 234
 	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
235
+	 * @param string $key
236
+	 * @param integer $expire
229 237
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
230 238
 	 */
231 239
 	abstract protected function addValue($key,$value,$expire);
@@ -234,6 +242,7 @@  discard block
 block discarded – undo
234 242
 	 * Deletes a value with the specified key from cache
235 243
 	 * This method should be implemented by child classes to delete the data from actual cache storage.
236 244
 	 * @param string the key of the value to be deleted
245
+	 * @param string $key
237 246
 	 * @return boolean if no error happens during deletion
238 247
 	 */
239 248
 	abstract protected function deleteValue($key);
@@ -409,6 +418,7 @@  discard block
 block discarded – undo
409 418
 	/**
410 419
 	 * Constructor.
411 420
 	 * @param string the directory to be checked
421
+	 * @param string $directory
412 422
 	 */
413 423
 	public function __construct($directory)
414 424
 	{
@@ -446,6 +456,7 @@  discard block
 block discarded – undo
446 456
 
447 457
 	/**
448 458
 	 * @param boolean whether the subdirectories of the directory will also be checked.
459
+	 * @param boolean $value
449 460
 	 */
450 461
 	public function setRecursiveCheck($value)
451 462
 	{
@@ -468,6 +479,7 @@  discard block
 block discarded – undo
468 479
 	 * @param int the depth of the subdirectories to be checked.
469 480
 	 * If the value is less than 0, it means unlimited depth.
470 481
 	 * If the value is 0, it means checking the files directly under the specified directory.
482
+	 * @param integer $value
471 483
 	 */
472 484
 	public function setRecursiveLevel($value)
473 485
 	{
@@ -490,6 +502,7 @@  discard block
 block discarded – undo
490 502
 	 * By default, it always returns true, meaning the file should be checked.
491 503
 	 * You may override this method to check only certain files.
492 504
 	 * @param string the name of the file that may be checked for dependency.
505
+	 * @param string $fileName
493 506
 	 * @return boolean whether this file should be checked.
494 507
 	 */
495 508
 	protected function validateFile($fileName)
@@ -503,6 +516,7 @@  discard block
 block discarded – undo
503 516
 	 * By default, it always returns true, meaning the subdirectory should be checked.
504 517
 	 * You may override this method to check only certain subdirectories.
505 518
 	 * @param string the name of the subdirectory that may be checked for dependency.
519
+	 * @param string $directory
506 520
 	 * @return boolean whether this subdirectory should be checked.
507 521
 	 */
508 522
 	protected function validateDirectory($directory)
@@ -516,6 +530,7 @@  discard block
 block discarded – undo
516 530
 	 * {@link setRecursiveCheck RecursiveCheck} is set true.
517 531
 	 * @param string the directory name
518 532
 	 * @param int level of the recursion
533
+	 * @param string $directory
519 534
 	 * @return array list of file modification time indexed by the file path
520 535
 	 */
521 536
 	protected function generateTimestamps($directory,$level=0)
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
  */
47 47
 abstract class TCache extends TModule implements ICache, ArrayAccess
48 48
 {
49
-	private $_prefix=null;
50
-	private $_primary=true;
49
+	private $_prefix = null;
50
+	private $_primary = true;
51 51
 
52 52
 	/**
53 53
 	 * Initializes the cache module.
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function init($config)
59 59
 	{
60
-		if($this->_prefix===null)
61
-			$this->_prefix=$this->getApplication()->getUniqueID();
62
-		if($this->_primary)
60
+		if ($this->_prefix === null)
61
+			$this->_prefix = $this->getApplication()->getUniqueID();
62
+		if ($this->_primary)
63 63
 		{
64
-			if($this->getApplication()->getCache()===null)
64
+			if ($this->getApplication()->getCache() === null)
65 65
 				$this->getApplication()->setCache($this);
66 66
 			else
67
-				throw new TConfigurationException('cache_primary_duplicated',get_class($this));
67
+				throw new TConfigurationException('cache_primary_duplicated', get_class($this));
68 68
 		}
69 69
 	}
70 70
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public function setPrimaryCache($value)
86 86
 	{
87
-		$this->_primary=TPropertyValue::ensureBoolean($value);
87
+		$this->_primary = TPropertyValue::ensureBoolean($value);
88 88
 	}
89 89
 
90 90
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public function setKeyPrefix($value)
103 103
 	{
104
-		$this->_prefix=$value;
104
+		$this->_prefix = $value;
105 105
 	}
106 106
 
107 107
 	/**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	protected function generateUniqueKey($key)
112 112
 	{
113
-		return md5($this->_prefix.$key);
113
+		return md5($this->_prefix . $key);
114 114
 	}
115 115
 
116 116
 	/**
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	public function get($id)
122 122
 	{
123
-		if(($data=$this->getValue($this->generateUniqueKey($id)))!==false)
123
+		if (($data = $this->getValue($this->generateUniqueKey($id))) !== false)
124 124
 		{
125
-			if(!is_array($data))
125
+			if (!is_array($data))
126 126
 				return false;
127
-			if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged())
127
+			if (!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged())
128 128
 				return $data[0];
129 129
 		}
130 130
 		return false;
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
 	 * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid.
143 143
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
144 144
 	 */
145
-	public function set($id,$value,$expire=0,$dependency=null)
145
+	public function set($id, $value, $expire = 0, $dependency = null)
146 146
 	{
147
-		if(empty($value) && $expire === 0)
147
+		if (empty($value) && $expire === 0)
148 148
 			$this->delete($id);
149 149
 		else
150 150
 		{
151
-			$data=array($value,$dependency);
152
-			return $this->setValue($this->generateUniqueKey($id),$data,$expire);
151
+			$data = array($value, $dependency);
152
+			return $this->setValue($this->generateUniqueKey($id), $data, $expire);
153 153
 		}
154 154
 	}
155 155
 
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
 	 * @param ICacheDependency dependency of the cached item. If the dependency changes, the item is labeled invalid.
163 163
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
164 164
 	 */
165
-	public function add($id,$value,$expire=0,$dependency=null)
165
+	public function add($id, $value, $expire = 0, $dependency = null)
166 166
 	{
167
-		if(empty($value) && $expire === 0)
167
+		if (empty($value) && $expire === 0)
168 168
 			return false;
169
-		$data=array($value,$dependency);
170
-		return $this->addValue($this->generateUniqueKey($id),$data,$expire);
169
+		$data = array($value, $dependency);
170
+		return $this->addValue($this->generateUniqueKey($id), $data, $expire);
171 171
 	}
172 172
 
173 173
 	/**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
215 215
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
216 216
 	 */
217
-	abstract protected function setValue($key,$value,$expire);
217
+	abstract protected function setValue($key, $value, $expire);
218 218
 
219 219
 	/**
220 220
 	 * Stores a value identified by a key into cache if the cache does not contain this key.
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * @param integer the number of seconds in which the cached value will expire. 0 means never expire.
229 229
 	 * @return boolean true if the value is successfully stored into cache, false otherwise
230 230
 	 */
231
-	abstract protected function addValue($key,$value,$expire);
231
+	abstract protected function addValue($key, $value, $expire);
232 232
 
233 233
 	/**
234 234
 	 * Deletes a value with the specified key from cache
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 */
359 359
 	public function setFileName($value)
360 360
 	{
361
-		$this->_fileName=$value;
362
-		$this->_timestamp=@filemtime($value);
361
+		$this->_fileName = $value;
362
+		$this->_timestamp = @filemtime($value);
363 363
 	}
364 364
 
365 365
 	/**
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 */
378 378
 	public function getHasChanged()
379 379
 	{
380
-		return @filemtime($this->_fileName)!==$this->_timestamp;
380
+		return @filemtime($this->_fileName) !== $this->_timestamp;
381 381
 	}
382 382
 }
383 383
 
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
  */
402 402
 class TDirectoryCacheDependency extends TCacheDependency
403 403
 {
404
-	private $_recursiveCheck=true;
405
-	private $_recursiveLevel=-1;
404
+	private $_recursiveCheck = true;
405
+	private $_recursiveLevel = -1;
406 406
 	private $_timestamps;
407 407
 	private $_directory;
408 408
 
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
 	 */
430 430
 	public function setDirectory($directory)
431 431
 	{
432
-		if(($path=realpath($directory))===false || !is_dir($path))
433
-			throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory);
434
-		$this->_directory=$path;
435
-		$this->_timestamps=$this->generateTimestamps($path);
432
+		if (($path = realpath($directory)) === false || !is_dir($path))
433
+			throw new TInvalidDataValueException('directorycachedependency_directory_invalid', $directory);
434
+		$this->_directory = $path;
435
+		$this->_timestamps = $this->generateTimestamps($path);
436 436
 	}
437 437
 
438 438
 	/**
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	 */
450 450
 	public function setRecursiveCheck($value)
451 451
 	{
452
-		$this->_recursiveCheck=TPropertyValue::ensureBoolean($value);
452
+		$this->_recursiveCheck = TPropertyValue::ensureBoolean($value);
453 453
 	}
454 454
 
455 455
 	/**
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 */
472 472
 	public function setRecursiveLevel($value)
473 473
 	{
474
-		$this->_recursiveLevel=TPropertyValue::ensureInteger($value);
474
+		$this->_recursiveLevel = TPropertyValue::ensureInteger($value);
475 475
 	}
476 476
 
477 477
 	/**
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 	 */
482 482
 	public function getHasChanged()
483 483
 	{
484
-		return $this->generateTimestamps($this->_directory)!=$this->_timestamps;
484
+		return $this->generateTimestamps($this->_directory) != $this->_timestamps;
485 485
 	}
486 486
 
487 487
 	/**
@@ -518,23 +518,23 @@  discard block
 block discarded – undo
518 518
 	 * @param int level of the recursion
519 519
 	 * @return array list of file modification time indexed by the file path
520 520
 	 */
521
-	protected function generateTimestamps($directory,$level=0)
521
+	protected function generateTimestamps($directory, $level = 0)
522 522
 	{
523
-		if(($dir=opendir($directory))===false)
524
-			throw new TIOException('directorycachedependency_directory_invalid',$directory);
525
-		$timestamps=array();
526
-		while(($file=readdir($dir))!==false)
523
+		if (($dir = opendir($directory)) === false)
524
+			throw new TIOException('directorycachedependency_directory_invalid', $directory);
525
+		$timestamps = array();
526
+		while (($file = readdir($dir)) !== false)
527 527
 		{
528
-			$path=$directory.DIRECTORY_SEPARATOR.$file;
529
-			if($file==='.' || $file==='..')
528
+			$path = $directory . DIRECTORY_SEPARATOR . $file;
529
+			if ($file === '.' || $file === '..')
530 530
 				continue;
531
-			else if(is_dir($path))
531
+			else if (is_dir($path))
532 532
 			{
533
-				if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path))
534
-					$timestamps=array_merge($this->generateTimestamps($path,$level+1));
533
+				if (($this->_recursiveLevel < 0 || $level < $this->_recursiveLevel) && $this->validateDirectory($path))
534
+					$timestamps = array_merge($this->generateTimestamps($path, $level + 1));
535 535
 			}
536
-			else if($this->validateFile($path))
537
-				$timestamps[$path]=filemtime($path);
536
+			else if ($this->validateFile($path))
537
+				$timestamps[$path] = filemtime($path);
538 538
 		}
539 539
 		closedir($dir);
540 540
 		return $timestamps;
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 	 */
583 583
 	public function setStateName($value)
584 584
 	{
585
-		$this->_stateName=$value;
586
-		$this->_stateValue=Prado::getApplication()->getGlobalState($value);
585
+		$this->_stateName = $value;
586
+		$this->_stateValue = Prado::getApplication()->getGlobalState($value);
587 587
 	}
588 588
 
589 589
 	/**
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 	 */
594 594
 	public function getHasChanged()
595 595
 	{
596
-		return $this->_stateValue!==Prado::getApplication()->getGlobalState($this->_stateName);
596
+		return $this->_stateValue !== Prado::getApplication()->getGlobalState($this->_stateName);
597 597
 	}
598 598
 }
599 599
 
@@ -616,15 +616,15 @@  discard block
 block discarded – undo
616 616
  */
617 617
 class TChainedCacheDependency extends TCacheDependency
618 618
 {
619
-	private $_dependencies=null;
619
+	private $_dependencies = null;
620 620
 
621 621
 	/**
622 622
 	 * @return TCacheDependencyList list of dependency objects
623 623
 	 */
624 624
 	public function getDependencies()
625 625
 	{
626
-		if($this->_dependencies===null)
627
-			$this->_dependencies=new TCacheDependencyList;
626
+		if ($this->_dependencies === null)
627
+			$this->_dependencies = new TCacheDependencyList;
628 628
 		return $this->_dependencies;
629 629
 	}
630 630
 
@@ -636,10 +636,10 @@  discard block
 block discarded – undo
636 636
 	 */
637 637
 	public function getHasChanged()
638 638
 	{
639
-		if($this->_dependencies!==null)
639
+		if ($this->_dependencies !== null)
640 640
 		{
641
-			foreach($this->_dependencies as $dependency)
642
-				if($dependency->getHasChanged())
641
+			foreach ($this->_dependencies as $dependency)
642
+				if ($dependency->getHasChanged())
643 643
 					return true;
644 644
 		}
645 645
 		return false;
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 	 */
673 673
 	public function getHasChanged()
674 674
 	{
675
-		return Prado::getApplication()->getMode()!==TApplicationMode::Performance;
675
+		return Prado::getApplication()->getMode() !== TApplicationMode::Performance;
676 676
 	}
677 677
 }
678 678
 
@@ -699,10 +699,10 @@  discard block
 block discarded – undo
699 699
 	 * @param mixed new item
700 700
 	 * @throws TInvalidDataTypeException if the item to be inserted is not a dependency instance
701 701
 	 */
702
-	public function insertAt($index,$item)
702
+	public function insertAt($index, $item)
703 703
 	{
704
-		if($item instanceof ICacheDependency)
705
-			parent::insertAt($index,$item);
704
+		if ($item instanceof ICacheDependency)
705
+			parent::insertAt($index, $item);
706 706
 		else
707 707
 			throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required');
708 708
 	}
Please login to merge, or discard this patch.
Braces   +45 added lines, -34 removed lines patch added patch discarded remove patch
@@ -57,14 +57,16 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function init($config)
59 59
 	{
60
-		if($this->_prefix===null)
61
-			$this->_prefix=$this->getApplication()->getUniqueID();
60
+		if($this->_prefix===null) {
61
+					$this->_prefix=$this->getApplication()->getUniqueID();
62
+		}
62 63
 		if($this->_primary)
63 64
 		{
64
-			if($this->getApplication()->getCache()===null)
65
-				$this->getApplication()->setCache($this);
66
-			else
67
-				throw new TConfigurationException('cache_primary_duplicated',get_class($this));
65
+			if($this->getApplication()->getCache()===null) {
66
+							$this->getApplication()->setCache($this);
67
+			} else {
68
+							throw new TConfigurationException('cache_primary_duplicated',get_class($this));
69
+			}
68 70
 		}
69 71
 	}
70 72
 
@@ -122,10 +124,12 @@  discard block
 block discarded – undo
122 124
 	{
123 125
 		if(($data=$this->getValue($this->generateUniqueKey($id)))!==false)
124 126
 		{
125
-			if(!is_array($data))
126
-				return false;
127
-			if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged())
128
-				return $data[0];
127
+			if(!is_array($data)) {
128
+							return false;
129
+			}
130
+			if(!($data[1] instanceof ICacheDependency) || !$data[1]->getHasChanged()) {
131
+							return $data[0];
132
+			}
129 133
 		}
130 134
 		return false;
131 135
 	}
@@ -144,9 +148,9 @@  discard block
 block discarded – undo
144 148
 	 */
145 149
 	public function set($id,$value,$expire=0,$dependency=null)
146 150
 	{
147
-		if(empty($value) && $expire === 0)
148
-			$this->delete($id);
149
-		else
151
+		if(empty($value) && $expire === 0) {
152
+					$this->delete($id);
153
+		} else
150 154
 		{
151 155
 			$data=array($value,$dependency);
152 156
 			return $this->setValue($this->generateUniqueKey($id),$data,$expire);
@@ -164,8 +168,9 @@  discard block
 block discarded – undo
164 168
 	 */
165 169
 	public function add($id,$value,$expire=0,$dependency=null)
166 170
 	{
167
-		if(empty($value) && $expire === 0)
168
-			return false;
171
+		if(empty($value) && $expire === 0) {
172
+					return false;
173
+		}
169 174
 		$data=array($value,$dependency);
170 175
 		return $this->addValue($this->generateUniqueKey($id),$data,$expire);
171 176
 	}
@@ -429,8 +434,9 @@  discard block
 block discarded – undo
429 434
 	 */
430 435
 	public function setDirectory($directory)
431 436
 	{
432
-		if(($path=realpath($directory))===false || !is_dir($path))
433
-			throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory);
437
+		if(($path=realpath($directory))===false || !is_dir($path)) {
438
+					throw new TInvalidDataValueException('directorycachedependency_directory_invalid',$directory);
439
+		}
434 440
 		$this->_directory=$path;
435 441
 		$this->_timestamps=$this->generateTimestamps($path);
436 442
 	}
@@ -520,21 +526,23 @@  discard block
 block discarded – undo
520 526
 	 */
521 527
 	protected function generateTimestamps($directory,$level=0)
522 528
 	{
523
-		if(($dir=opendir($directory))===false)
524
-			throw new TIOException('directorycachedependency_directory_invalid',$directory);
529
+		if(($dir=opendir($directory))===false) {
530
+					throw new TIOException('directorycachedependency_directory_invalid',$directory);
531
+		}
525 532
 		$timestamps=array();
526 533
 		while(($file=readdir($dir))!==false)
527 534
 		{
528 535
 			$path=$directory.DIRECTORY_SEPARATOR.$file;
529
-			if($file==='.' || $file==='..')
530
-				continue;
531
-			else if(is_dir($path))
536
+			if($file==='.' || $file==='..') {
537
+							continue;
538
+			} else if(is_dir($path))
532 539
 			{
533
-				if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path))
534
-					$timestamps=array_merge($this->generateTimestamps($path,$level+1));
540
+				if(($this->_recursiveLevel<0 || $level<$this->_recursiveLevel) && $this->validateDirectory($path)) {
541
+									$timestamps=array_merge($this->generateTimestamps($path,$level+1));
542
+				}
543
+			} else if($this->validateFile($path)) {
544
+							$timestamps[$path]=filemtime($path);
535 545
 			}
536
-			else if($this->validateFile($path))
537
-				$timestamps[$path]=filemtime($path);
538 546
 		}
539 547
 		closedir($dir);
540 548
 		return $timestamps;
@@ -623,8 +631,9 @@  discard block
 block discarded – undo
623 631
 	 */
624 632
 	public function getDependencies()
625 633
 	{
626
-		if($this->_dependencies===null)
627
-			$this->_dependencies=new TCacheDependencyList;
634
+		if($this->_dependencies===null) {
635
+					$this->_dependencies=new TCacheDependencyList;
636
+		}
628 637
 		return $this->_dependencies;
629 638
 	}
630 639
 
@@ -638,9 +647,10 @@  discard block
 block discarded – undo
638 647
 	{
639 648
 		if($this->_dependencies!==null)
640 649
 		{
641
-			foreach($this->_dependencies as $dependency)
642
-				if($dependency->getHasChanged())
650
+			foreach($this->_dependencies as $dependency) {
651
+							if($dependency->getHasChanged())
643 652
 					return true;
653
+			}
644 654
 		}
645 655
 		return false;
646 656
 	}
@@ -701,10 +711,11 @@  discard block
 block discarded – undo
701 711
 	 */
702 712
 	public function insertAt($index,$item)
703 713
 	{
704
-		if($item instanceof ICacheDependency)
705
-			parent::insertAt($index,$item);
706
-		else
707
-			throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required');
714
+		if($item instanceof ICacheDependency) {
715
+					parent::insertAt($index,$item);
716
+		} else {
717
+					throw new TInvalidDataTypeException('cachedependencylist_cachedependency_required');
718
+		}
708 719
 	}
709 720
 }
710 721
 
Please login to merge, or discard this patch.
framework/Collections/TAttributeCollection.php 4 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -93,6 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 	/**
95 95
 	 * @param boolean whether the keys are case-sensitive.
96
+	 * @param boolean $value
96 97
 	 */
97 98
 	public function setCaseSensitive($value)
98 99
 	{
@@ -126,6 +127,7 @@  discard block
 block discarded – undo
126 127
 	 * Removes an item from the map by its key.
127 128
 	 * This overrides the parent implementation by converting the key to lower case first if CaseSensitive is false.
128 129
 	 * @param mixed the key of the item to be removed
130
+	 * @param string $key
129 131
 	 * @return mixed the removed value, null if no such key exists.
130 132
 	 */
131 133
 	public function remove($key)
@@ -149,6 +151,7 @@  discard block
 block discarded – undo
149 151
 	 * This method overrides parent implementation by returning true
150 152
 	 * if the collection contains the named key.
151 153
 	 * @param string the property name
154
+	 * @param string $name
152 155
 	 * @return boolean whether the property is defined
153 156
 	 */
154 157
 	public function hasProperty($name)
@@ -161,6 +164,7 @@  discard block
 block discarded – undo
161 164
 	 * This method overrides parent implementation by returning true
162 165
 	 * if the collection contains the named key.
163 166
 	 * @param string the property name
167
+	 * @param string $name
164 168
 	 * @return boolean whether the property can be read
165 169
 	 */
166 170
 	public function canGetProperty($name)
@@ -173,6 +177,7 @@  discard block
 block discarded – undo
173 177
 	 * This method overrides parent implementation by always returning true
174 178
 	 * because you can always add a new value to the collection.
175 179
 	 * @param string the property name
180
+	 * @param string $name
176 181
 	 * @return boolean true
177 182
 	 */
178 183
 	public function canSetProperty($name)
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TAttributeCollection classes
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Collections
10
- */
3
+	 * TAttributeCollection classes
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Collections
10
+	 */
11 11
 
12 12
 /**
13 13
  * Includes TMap class
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  */
43 43
 class TAttributeCollection extends TMap
44 44
 {
45
-	private $_caseSensitive=false;
45
+	private $_caseSensitive = false;
46 46
 
47 47
 	/**
48 48
 	 * Returns an array with the names of all variables of this object that should NOT be serialized
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	protected function __getZappableSleepProps(&$exprops)
54 54
 	{
55 55
 		parent::__getZappableSleepProps($exprops);
56
-		if ($this->_caseSensitive===false)
56
+		if ($this->_caseSensitive === false)
57 57
 			$exprops[] = "\0TAttributeCollection\0_caseSensitive";
58 58
 	}
59 59
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function __get($name)
69 69
 	{
70
-		return $this->contains($name)?$this->itemAt($name):parent::__get($name);
70
+		return $this->contains($name) ? $this->itemAt($name) : parent::__get($name);
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	 * @param mixed the property value or event handler
79 79
 	 * @throws TInvalidOperationException If the property is not defined or read-only.
80 80
 	 */
81
-	public function __set($name,$value)
81
+	public function __set($name, $value)
82 82
 	{
83
-		$this->add($name,$value);
83
+		$this->add($name, $value);
84 84
 	}
85 85
 
86 86
 	/**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function setCaseSensitive($value)
98 98
 	{
99
-		$this->_caseSensitive=TPropertyValue::ensureBoolean($value);
99
+		$this->_caseSensitive = TPropertyValue::ensureBoolean($value);
100 100
 	}
101 101
 
102 102
 	/**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function itemAt($key)
109 109
 	{
110
-		return parent::itemAt($this->_caseSensitive?$key:strtolower($key));
110
+		return parent::itemAt($this->_caseSensitive ? $key : strtolower($key));
111 111
 	}
112 112
 
113 113
 
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
 	 * @param mixed key
118 118
 	 * @param mixed value
119 119
 	 */
120
-	public function add($key,$value)
120
+	public function add($key, $value)
121 121
 	{
122
-		parent::add($this->_caseSensitive?$key:strtolower($key),$value);
122
+		parent::add($this->_caseSensitive ? $key : strtolower($key), $value);
123 123
 	}
124 124
 
125 125
 	/**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function remove($key)
132 132
 	{
133
-		return parent::remove($this->_caseSensitive?$key:strtolower($key));
133
+		return parent::remove($this->_caseSensitive ? $key : strtolower($key));
134 134
 	}
135 135
 
136 136
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function contains($key)
143 143
 	{
144
-		return parent::contains($this->_caseSensitive?$key:strtolower($key));
144
+		return parent::contains($this->_caseSensitive ? $key : strtolower($key));
145 145
 	}
146 146
 
147 147
 	/**
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@
 block discarded – undo
53 53
 	protected function __getZappableSleepProps(&$exprops)
54 54
 	{
55 55
 		parent::__getZappableSleepProps($exprops);
56
-		if ($this->_caseSensitive===false)
57
-			$exprops[] = "\0TAttributeCollection\0_caseSensitive";
56
+		if ($this->_caseSensitive===false) {
57
+					$exprops[] = "\0TAttributeCollection\0_caseSensitive";
58
+		}
58 59
 	}
59 60
 
60 61
 	/**
Please login to merge, or discard this patch.
framework/Collections/TDummyDataSource.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -31,6 +31,7 @@
 block discarded – undo
31 31
 	/**
32 32
 	 * Constructor.
33 33
 	 * @param integer number of (virtual) items in the data source.
34
+	 * @param integer $count
34 35
 	 */
35 36
 	public function __construct($count)
36 37
 	{
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	public function __construct($count)
36 36
 	{
37
-		$this->_count=$count;
37
+		$this->_count = $count;
38 38
 	}
39 39
 
40 40
 	/**
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function __construct($count)
90 90
 	{
91
-		$this->_count=$count;
92
-		$this->_index=0;
91
+		$this->_count = $count;
92
+		$this->_index = 0;
93 93
 	}
94 94
 
95 95
 	/**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public function rewind()
100 100
 	{
101
-		$this->_index=0;
101
+		$this->_index = 0;
102 102
 	}
103 103
 
104 104
 	/**
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	public function valid()
139 139
 	{
140
-		return $this->_index<$this->_count;
140
+		return $this->_index < $this->_count;
141 141
 	}
142 142
 }
143 143
 
Please login to merge, or discard this patch.
framework/Collections/TList.php 4 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,6 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
 	/**
77 77
 	 * @param boolean whether this list is read-only or not
78
+	 * @param boolean $value
78 79
 	 */
79 80
 	protected function setReadOnly($value)
80 81
 	{
@@ -277,7 +278,7 @@  discard block
 block discarded – undo
277 278
 	 * Finds the base item.  If found, the item is inserted after it.
278 279
 	 * @param mixed the base item which comes before the second parameter when added to the list
279 280
 	 * @param mixed the item
280
-	 * @return int the index where the item is inserted
281
+	 * @return double the index where the item is inserted
281 282
 	 * @throws TInvalidDataValueException if the base item is not within this list
282 283
 	 * @throws TInvalidOperationException if the list is read-only
283 284
 	 * @since 3.2a
@@ -369,6 +370,8 @@  discard block
 block discarded – undo
369 370
 	 * This method is required by the interface ArrayAccess.
370 371
 	 * @param integer the offset to set item
371 372
 	 * @param mixed the item value
373
+	 * @param null|integer $offset
374
+	 * @param integer $item
372 375
 	 */
373 376
 	public function offsetSet($offset,$item)
374 377
 	{
@@ -385,6 +388,7 @@  discard block
 block discarded – undo
385 388
 	 * Unsets the item at the specified offset.
386 389
 	 * This method is required by the interface ArrayAccess.
387 390
 	 * @param integer the offset to unset item
391
+	 * @param integer $offset
388 392
 	 */
389 393
 	public function offsetUnset($offset)
390 394
 	{
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TList, TListIterator classes
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Collections
10
- */
3
+	 * TList, TListIterator classes
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Collections
10
+	 */
11 11
 
12 12
 /**
13 13
  * TList class
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -34,22 +34,22 @@  discard block
 block discarded – undo
34 34
  * @package System.Collections
35 35
  * @since 3.0
36 36
  */
37
-class TList extends TComponent implements IteratorAggregate,ArrayAccess,Countable
37
+class TList extends TComponent implements IteratorAggregate, ArrayAccess, Countable
38 38
 {
39 39
 	/**
40 40
 	 * internal data storage
41 41
 	 * @var array
42 42
 	 */
43
-	private $_d=array();
43
+	private $_d = array();
44 44
 	/**
45 45
 	 * number of items
46 46
 	 * @var integer
47 47
 	 */
48
-	private $_c=0;
48
+	private $_c = 0;
49 49
 	/**
50 50
 	 * @var boolean whether this list is read-only
51 51
 	 */
52
-	private $_r=false;
52
+	private $_r = false;
53 53
 
54 54
 	/**
55 55
 	 * Constructor.
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	 * @param boolean whether the list is read-only
59 59
 	 * @throws TInvalidDataTypeException If data is not null and neither an array nor an iterator.
60 60
 	 */
61
-	public function __construct($data=null,$readOnly=false)
61
+	public function __construct($data = null, $readOnly = false)
62 62
 	{
63
-		if($data!==null)
63
+		if ($data !== null)
64 64
 			$this->copyFrom($data);
65 65
 		$this->setReadOnly($readOnly);
66 66
 	}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	protected function setReadOnly($value)
80 80
 	{
81
-		$this->_r=TPropertyValue::ensureBoolean($value);
81
+		$this->_r = TPropertyValue::ensureBoolean($value);
82 82
 	}
83 83
 
84 84
 	/**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function getIterator()
90 90
 	{
91
-		return new ArrayIterator( $this->_d );
91
+		return new ArrayIterator($this->_d);
92 92
 	}
93 93
 
94 94
 	/**
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function itemAt($index)
120 120
 	{
121
-		if($index>=0 && $index<$this->_c)
121
+		if ($index >= 0 && $index < $this->_c)
122 122
 			return $this->_d[$index];
123 123
 		else
124
-			throw new TInvalidDataValueException('list_index_invalid',$index);
124
+			throw new TInvalidDataValueException('list_index_invalid', $index);
125 125
 	}
126 126
 
127 127
 	/**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function add($item)
134 134
 	{
135
-		$this->insertAt($this->_c,$item);
136
-		return $this->_c-1;
135
+		$this->insertAt($this->_c, $item);
136
+		return $this->_c - 1;
137 137
 	}
138 138
 
139 139
 	/**
@@ -145,22 +145,22 @@  discard block
 block discarded – undo
145 145
 	 * @throws TInvalidDataValueException If the index specified exceeds the bound
146 146
 	 * @throws TInvalidOperationException if the list is read-only
147 147
 	 */
148
-	public function insertAt($index,$item)
148
+	public function insertAt($index, $item)
149 149
 	{
150
-		if(!$this->_r)
150
+		if (!$this->_r)
151 151
 		{
152
-			if($index===$this->_c)
153
-				$this->_d[$this->_c++]=$item;
154
-			else if($index>=0 && $index<$this->_c)
152
+			if ($index === $this->_c)
153
+				$this->_d[$this->_c++] = $item;
154
+			else if ($index >= 0 && $index < $this->_c)
155 155
 			{
156
-				array_splice($this->_d,$index,0,array($item));
156
+				array_splice($this->_d, $index, 0, array($item));
157 157
 				$this->_c++;
158 158
 			}
159 159
 			else
160
-				throw new TInvalidDataValueException('list_index_invalid',$index);
160
+				throw new TInvalidDataValueException('list_index_invalid', $index);
161 161
 		}
162 162
 		else
163
-			throw new TInvalidOperationException('list_readonly',get_class($this));
163
+			throw new TInvalidOperationException('list_readonly', get_class($this));
164 164
 	}
165 165
 
166 166
 	/**
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function remove($item)
176 176
 	{
177
-		if(!$this->_r)
177
+		if (!$this->_r)
178 178
 		{
179
-			if(($index=$this->indexOf($item))>=0)
179
+			if (($index = $this->indexOf($item)) >= 0)
180 180
 			{
181 181
 				$this->removeAt($index);
182 182
 				return $index;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 				throw new TInvalidDataValueException('list_item_inexistent');
186 186
 		}
187 187
 		else
188
-			throw new TInvalidOperationException('list_readonly',get_class($this));
188
+			throw new TInvalidOperationException('list_readonly', get_class($this));
189 189
 	}
190 190
 
191 191
 	/**
@@ -197,25 +197,25 @@  discard block
 block discarded – undo
197 197
 	 */
198 198
 	public function removeAt($index)
199 199
 	{
200
-		if(!$this->_r)
200
+		if (!$this->_r)
201 201
 		{
202
-			if($index>=0 && $index<$this->_c)
202
+			if ($index >= 0 && $index < $this->_c)
203 203
 			{
204 204
 				$this->_c--;
205
-				if($index===$this->_c)
205
+				if ($index === $this->_c)
206 206
 					return array_pop($this->_d);
207 207
 				else
208 208
 				{
209
-					$item=$this->_d[$index];
210
-					array_splice($this->_d,$index,1);
209
+					$item = $this->_d[$index];
210
+					array_splice($this->_d, $index, 1);
211 211
 					return $item;
212 212
 				}
213 213
 			}
214 214
 			else
215
-				throw new TInvalidDataValueException('list_index_invalid',$index);
215
+				throw new TInvalidDataValueException('list_index_invalid', $index);
216 216
 		}
217 217
 		else
218
-			throw new TInvalidOperationException('list_readonly',get_class($this));
218
+			throw new TInvalidOperationException('list_readonly', get_class($this));
219 219
 	}
220 220
 
221 221
 	/**
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	public function clear()
226 226
 	{
227
-		for($i=$this->_c-1;$i>=0;--$i)
227
+		for ($i = $this->_c - 1; $i >= 0; --$i)
228 228
 			$this->removeAt($i);
229 229
 	}
230 230
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	public function contains($item)
236 236
 	{
237
-		return $this->indexOf($item)>=0;
237
+		return $this->indexOf($item) >= 0;
238 238
 	}
239 239
 
240 240
 	/**
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public function indexOf($item)
245 245
 	{
246
-		if(($index=array_search($item,$this->_d,true))===false)
246
+		if (($index = array_search($item, $this->_d, true)) === false)
247 247
 			return -1;
248 248
 		else
249 249
 			return $index;
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	public function insertBefore($baseitem, $item)
262 262
 	{
263
-		if(!$this->_r)
263
+		if (!$this->_r)
264 264
 		{
265
-			if(($index = $this->indexOf($baseitem)) == -1)
265
+			if (($index = $this->indexOf($baseitem)) == -1)
266 266
 				throw new TInvalidDataValueException('list_item_inexistent');
267 267
 
268 268
 			$this->insertAt($index, $item);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			return $index;
271 271
 		}
272 272
 		else
273
-			throw new TInvalidOperationException('list_readonly',get_class($this));
273
+			throw new TInvalidOperationException('list_readonly', get_class($this));
274 274
 	}
275 275
 
276 276
 	/**
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	public function insertAfter($baseitem, $item)
286 286
 	{
287
-		if(!$this->_r)
287
+		if (!$this->_r)
288 288
 		{
289
-			if(($index = $this->indexOf($baseitem)) == -1)
289
+			if (($index = $this->indexOf($baseitem)) == -1)
290 290
 				throw new TInvalidDataValueException('list_item_inexistent');
291 291
 
292 292
 			$this->insertAt($index + 1, $item);
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 			return $index + 1;
295 295
 		}
296 296
 		else
297
-			throw new TInvalidOperationException('list_readonly',get_class($this));
297
+			throw new TInvalidOperationException('list_readonly', get_class($this));
298 298
 	}
299 299
 
300 300
 	/**
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	public function copyFrom($data)
315 315
 	{
316
-		if(is_array($data) || ($data instanceof Traversable))
316
+		if (is_array($data) || ($data instanceof Traversable))
317 317
 		{
318
-			if($this->_c>0)
318
+			if ($this->_c > 0)
319 319
 				$this->clear();
320
-			foreach($data as $item)
320
+			foreach ($data as $item)
321 321
 				$this->add($item);
322 322
 		}
323
-		else if($data!==null)
323
+		else if ($data !== null)
324 324
 			throw new TInvalidDataTypeException('list_data_not_iterable');
325 325
 	}
326 326
 
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 	 */
333 333
 	public function mergeWith($data)
334 334
 	{
335
-		if(is_array($data) || ($data instanceof Traversable))
335
+		if (is_array($data) || ($data instanceof Traversable))
336 336
 		{
337
-			foreach($data as $item)
337
+			foreach ($data as $item)
338 338
 				$this->add($item);
339 339
 		}
340
-		else if($data!==null)
340
+		else if ($data !== null)
341 341
 			throw new TInvalidDataTypeException('list_data_not_iterable');
342 342
 	}
343 343
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	 */
350 350
 	public function offsetExists($offset)
351 351
 	{
352
-		return ($offset>=0 && $offset<$this->_c);
352
+		return ($offset >= 0 && $offset < $this->_c);
353 353
 	}
354 354
 
355 355
 	/**
@@ -370,14 +370,14 @@  discard block
 block discarded – undo
370 370
 	 * @param integer the offset to set item
371 371
 	 * @param mixed the item value
372 372
 	 */
373
-	public function offsetSet($offset,$item)
373
+	public function offsetSet($offset, $item)
374 374
 	{
375
-		if($offset===null || $offset===$this->_c)
376
-			$this->insertAt($this->_c,$item);
375
+		if ($offset === null || $offset === $this->_c)
376
+			$this->insertAt($this->_c, $item);
377 377
 		else
378 378
 		{
379 379
 			$this->removeAt($offset);
380
-			$this->insertAt($offset,$item);
380
+			$this->insertAt($offset, $item);
381 381
 		}
382 382
 	}
383 383
 
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 	 */
428 428
 	public function __construct(&$data)
429 429
 	{
430
-		$this->_d=&$data;
431
-		$this->_i=0;
432
-		$this->_c=count($this->_d);
430
+		$this->_d = &$data;
431
+		$this->_i = 0;
432
+		$this->_c = count($this->_d);
433 433
 	}
434 434
 
435 435
 	/**
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	 */
439 439
 	public function rewind()
440 440
 	{
441
-		$this->_i=0;
441
+		$this->_i = 0;
442 442
 	}
443 443
 
444 444
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 */
478 478
 	public function valid()
479 479
 	{
480
-		return $this->_i<$this->_c;
480
+		return $this->_i < $this->_c;
481 481
 	}
482 482
 }
483 483
 
Please login to merge, or discard this patch.
Braces   +60 added lines, -51 removed lines patch added patch discarded remove patch
@@ -60,8 +60,9 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function __construct($data=null,$readOnly=false)
62 62
 	{
63
-		if($data!==null)
64
-			$this->copyFrom($data);
63
+		if($data!==null) {
64
+					$this->copyFrom($data);
65
+		}
65 66
 		$this->setReadOnly($readOnly);
66 67
 	}
67 68
 
@@ -118,10 +119,11 @@  discard block
 block discarded – undo
118 119
 	 */
119 120
 	public function itemAt($index)
120 121
 	{
121
-		if($index>=0 && $index<$this->_c)
122
-			return $this->_d[$index];
123
-		else
124
-			throw new TInvalidDataValueException('list_index_invalid',$index);
122
+		if($index>=0 && $index<$this->_c) {
123
+					return $this->_d[$index];
124
+		} else {
125
+					throw new TInvalidDataValueException('list_index_invalid',$index);
126
+		}
125 127
 	}
126 128
 
127 129
 	/**
@@ -149,18 +151,18 @@  discard block
 block discarded – undo
149 151
 	{
150 152
 		if(!$this->_r)
151 153
 		{
152
-			if($index===$this->_c)
153
-				$this->_d[$this->_c++]=$item;
154
-			else if($index>=0 && $index<$this->_c)
154
+			if($index===$this->_c) {
155
+							$this->_d[$this->_c++]=$item;
156
+			} else if($index>=0 && $index<$this->_c)
155 157
 			{
156 158
 				array_splice($this->_d,$index,0,array($item));
157 159
 				$this->_c++;
160
+			} else {
161
+							throw new TInvalidDataValueException('list_index_invalid',$index);
158 162
 			}
159
-			else
160
-				throw new TInvalidDataValueException('list_index_invalid',$index);
163
+		} else {
164
+					throw new TInvalidOperationException('list_readonly',get_class($this));
161 165
 		}
162
-		else
163
-			throw new TInvalidOperationException('list_readonly',get_class($this));
164 166
 	}
165 167
 
166 168
 	/**
@@ -180,12 +182,12 @@  discard block
 block discarded – undo
180 182
 			{
181 183
 				$this->removeAt($index);
182 184
 				return $index;
185
+			} else {
186
+							throw new TInvalidDataValueException('list_item_inexistent');
183 187
 			}
184
-			else
185
-				throw new TInvalidDataValueException('list_item_inexistent');
188
+		} else {
189
+					throw new TInvalidOperationException('list_readonly',get_class($this));
186 190
 		}
187
-		else
188
-			throw new TInvalidOperationException('list_readonly',get_class($this));
189 191
 	}
190 192
 
191 193
 	/**
@@ -202,20 +204,20 @@  discard block
 block discarded – undo
202 204
 			if($index>=0 && $index<$this->_c)
203 205
 			{
204 206
 				$this->_c--;
205
-				if($index===$this->_c)
206
-					return array_pop($this->_d);
207
-				else
207
+				if($index===$this->_c) {
208
+									return array_pop($this->_d);
209
+				} else
208 210
 				{
209 211
 					$item=$this->_d[$index];
210 212
 					array_splice($this->_d,$index,1);
211 213
 					return $item;
212 214
 				}
215
+			} else {
216
+							throw new TInvalidDataValueException('list_index_invalid',$index);
213 217
 			}
214
-			else
215
-				throw new TInvalidDataValueException('list_index_invalid',$index);
218
+		} else {
219
+					throw new TInvalidOperationException('list_readonly',get_class($this));
216 220
 		}
217
-		else
218
-			throw new TInvalidOperationException('list_readonly',get_class($this));
219 221
 	}
220 222
 
221 223
 	/**
@@ -224,8 +226,9 @@  discard block
 block discarded – undo
224 226
 	 */
225 227
 	public function clear()
226 228
 	{
227
-		for($i=$this->_c-1;$i>=0;--$i)
228
-			$this->removeAt($i);
229
+		for($i=$this->_c-1;$i>=0;--$i) {
230
+					$this->removeAt($i);
231
+		}
229 232
 	}
230 233
 
231 234
 	/**
@@ -243,10 +246,11 @@  discard block
 block discarded – undo
243 246
 	 */
244 247
 	public function indexOf($item)
245 248
 	{
246
-		if(($index=array_search($item,$this->_d,true))===false)
247
-			return -1;
248
-		else
249
-			return $index;
249
+		if(($index=array_search($item,$this->_d,true))===false) {
250
+					return -1;
251
+		} else {
252
+					return $index;
253
+		}
250 254
 	}
251 255
 
252 256
 	/**
@@ -262,15 +266,16 @@  discard block
 block discarded – undo
262 266
 	{
263 267
 		if(!$this->_r)
264 268
 		{
265
-			if(($index = $this->indexOf($baseitem)) == -1)
266
-				throw new TInvalidDataValueException('list_item_inexistent');
269
+			if(($index = $this->indexOf($baseitem)) == -1) {
270
+							throw new TInvalidDataValueException('list_item_inexistent');
271
+			}
267 272
 
268 273
 			$this->insertAt($index, $item);
269 274
 
270 275
 			return $index;
276
+		} else {
277
+					throw new TInvalidOperationException('list_readonly',get_class($this));
271 278
 		}
272
-		else
273
-			throw new TInvalidOperationException('list_readonly',get_class($this));
274 279
 	}
275 280
 
276 281
 	/**
@@ -286,15 +291,16 @@  discard block
 block discarded – undo
286 291
 	{
287 292
 		if(!$this->_r)
288 293
 		{
289
-			if(($index = $this->indexOf($baseitem)) == -1)
290
-				throw new TInvalidDataValueException('list_item_inexistent');
294
+			if(($index = $this->indexOf($baseitem)) == -1) {
295
+							throw new TInvalidDataValueException('list_item_inexistent');
296
+			}
291 297
 
292 298
 			$this->insertAt($index + 1, $item);
293 299
 
294 300
 			return $index + 1;
301
+		} else {
302
+					throw new TInvalidOperationException('list_readonly',get_class($this));
295 303
 		}
296
-		else
297
-			throw new TInvalidOperationException('list_readonly',get_class($this));
298 304
 	}
299 305
 
300 306
 	/**
@@ -315,13 +321,15 @@  discard block
 block discarded – undo
315 321
 	{
316 322
 		if(is_array($data) || ($data instanceof Traversable))
317 323
 		{
318
-			if($this->_c>0)
319
-				$this->clear();
320
-			foreach($data as $item)
321
-				$this->add($item);
324
+			if($this->_c>0) {
325
+							$this->clear();
326
+			}
327
+			foreach($data as $item) {
328
+							$this->add($item);
329
+			}
330
+		} else if($data!==null) {
331
+					throw new TInvalidDataTypeException('list_data_not_iterable');
322 332
 		}
323
-		else if($data!==null)
324
-			throw new TInvalidDataTypeException('list_data_not_iterable');
325 333
 	}
326 334
 
327 335
 	/**
@@ -334,11 +342,12 @@  discard block
 block discarded – undo
334 342
 	{
335 343
 		if(is_array($data) || ($data instanceof Traversable))
336 344
 		{
337
-			foreach($data as $item)
338
-				$this->add($item);
345
+			foreach($data as $item) {
346
+							$this->add($item);
347
+			}
348
+		} else if($data!==null) {
349
+					throw new TInvalidDataTypeException('list_data_not_iterable');
339 350
 		}
340
-		else if($data!==null)
341
-			throw new TInvalidDataTypeException('list_data_not_iterable');
342 351
 	}
343 352
 
344 353
 	/**
@@ -372,9 +381,9 @@  discard block
 block discarded – undo
372 381
 	 */
373 382
 	public function offsetSet($offset,$item)
374 383
 	{
375
-		if($offset===null || $offset===$this->_c)
376
-			$this->insertAt($this->_c,$item);
377
-		else
384
+		if($offset===null || $offset===$this->_c) {
385
+					$this->insertAt($this->_c,$item);
386
+		} else
378 387
 		{
379 388
 			$this->removeAt($offset);
380 389
 			$this->insertAt($offset,$item);
Please login to merge, or discard this patch.
framework/Collections/TPagedDataSource.php 3 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -63,6 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
 	/**
65 65
 	 * @param mixed original data source
66
+	 * @param Traversable $value
66 67
 	 */
67 68
 	public function setDataSource($value)
68 69
 	{
@@ -88,6 +89,7 @@  discard block
 block discarded – undo
88 89
 
89 90
 	/**
90 91
 	 * @param integer number of items in each page
92
+	 * @param integer $value
91 93
 	 */
92 94
 	public function setPageSize($value)
93 95
 	{
@@ -107,6 +109,7 @@  discard block
 block discarded – undo
107 109
 
108 110
 	/**
109 111
 	 * @param integer current page index
112
+	 * @param integer $value
110 113
 	 */
111 114
 	public function setCurrentPageIndex($value)
112 115
 	{
@@ -125,6 +128,7 @@  discard block
 block discarded – undo
125 128
 
126 129
 	/**
127 130
 	 * @param boolean whether to allow paging
131
+	 * @param boolean $value
128 132
 	 */
129 133
 	public function setAllowPaging($value)
130 134
 	{
@@ -141,6 +145,7 @@  discard block
 block discarded – undo
141 145
 
142 146
 	/**
143 147
 	 * @param boolean whether to allow custom paging
148
+	 * @param boolean $value
144 149
 	 */
145 150
 	public function setAllowCustomPaging($value)
146 151
 	{
@@ -157,6 +162,7 @@  discard block
 block discarded – undo
157 162
 
158 163
 	/**
159 164
 	 * @param integer user-assigned number of items in data source
165
+	 * @param integer $value
160 166
 	 */
161 167
 	public function setVirtualItemCount($value)
162 168
 	{
@@ -290,6 +296,8 @@  discard block
 block discarded – undo
290 296
 	 * @param TList the data to be iterated through
291 297
 	 * @param integer start index
292 298
 	 * @param integer number of items to be iterated through
299
+	 * @param integer $startIndex
300
+	 * @param integer $count
293 301
 	 */
294 302
 	public function __construct(TList $list,$startIndex,$count)
295 303
 	{
@@ -374,6 +382,8 @@  discard block
 block discarded – undo
374 382
 	/**
375 383
 	 * Constructor.
376 384
 	 * @param array the data to be iterated through
385
+	 * @param integer $startIndex
386
+	 * @param integer $count
377 387
 	 */
378 388
 	public function __construct(TMap $map,$startIndex,$count)
379 389
 	{
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -26,32 +26,32 @@  discard block
 block discarded – undo
26 26
  * @package System.Collections
27 27
  * @since 3.0
28 28
  */
29
-class TPagedDataSource extends TComponent implements IteratorAggregate,Countable
29
+class TPagedDataSource extends TComponent implements IteratorAggregate, Countable
30 30
 {
31 31
 	/**
32 32
 	 * @var mixed original data source
33 33
 	 */
34
-	private $_dataSource=null;
34
+	private $_dataSource = null;
35 35
 	/**
36 36
 	 * @var integer number of items in each page
37 37
 	 */
38
-	private $_pageSize=10;
38
+	private $_pageSize = 10;
39 39
 	/**
40 40
 	 * @var integer current page index
41 41
 	 */
42
-	private $_currentPageIndex=0;
42
+	private $_currentPageIndex = 0;
43 43
 	/**
44 44
 	 * @var boolean whether to allow paging
45 45
 	 */
46
-	private $_allowPaging=false;
46
+	private $_allowPaging = false;
47 47
 	/**
48 48
 	 * @var boolean whether to allow custom paging
49 49
 	 */
50
-	private $_allowCustomPaging=false;
50
+	private $_allowCustomPaging = false;
51 51
 	/**
52 52
 	 * @var integer user-assigned number of items in data source
53 53
 	 */
54
-	private $_virtualCount=0;
54
+	private $_virtualCount = 0;
55 55
 
56 56
 	/**
57 57
 	 * @return mixed original data source. Defaults to null.
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function setDataSource($value)
68 68
 	{
69
-		if(!($value instanceof TMap) && !($value instanceof TList))
69
+		if (!($value instanceof TMap) && !($value instanceof TList))
70 70
 		{
71
-			if(is_array($value))
72
-				$value=new TMap($value);
73
-			else if($value instanceof Traversable)
74
-				$value=new TList($value);
75
-			else if($value!==null)
71
+			if (is_array($value))
72
+				$value = new TMap($value);
73
+			else if ($value instanceof Traversable)
74
+				$value = new TList($value);
75
+			else if ($value !== null)
76 76
 				throw new TInvalidDataTypeException('pageddatasource_datasource_invalid');
77 77
 		}
78
-		$this->_dataSource=$value;
78
+		$this->_dataSource = $value;
79 79
 	}
80 80
 
81 81
 	/**
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function setPageSize($value)
93 93
 	{
94
-		if(($value=TPropertyValue::ensureInteger($value))>0)
95
-			$this->_pageSize=$value;
94
+		if (($value = TPropertyValue::ensureInteger($value)) > 0)
95
+			$this->_pageSize = $value;
96 96
 		else
97 97
 			throw new TInvalidDataValueException('pageddatasource_pagesize_invalid');
98 98
 	}
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function setCurrentPageIndex($value)
112 112
 	{
113
-		if(($value=TPropertyValue::ensureInteger($value))<0)
114
-			$value=0;
115
-		$this->_currentPageIndex=$value;
113
+		if (($value = TPropertyValue::ensureInteger($value)) < 0)
114
+			$value = 0;
115
+		$this->_currentPageIndex = $value;
116 116
 	}
117 117
 
118 118
 	/**
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function setAllowPaging($value)
130 130
 	{
131
-		$this->_allowPaging=TPropertyValue::ensureBoolean($value);
131
+		$this->_allowPaging = TPropertyValue::ensureBoolean($value);
132 132
 	}
133 133
 
134 134
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	public function setAllowCustomPaging($value)
146 146
 	{
147
-		$this->_allowCustomPaging=TPropertyValue::ensureBoolean($value);
147
+		$this->_allowCustomPaging = TPropertyValue::ensureBoolean($value);
148 148
 	}
149 149
 
150 150
 	/**
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function setVirtualItemCount($value)
162 162
 	{
163
-		if(($value=TPropertyValue::ensureInteger($value))>=0)
164
-			$this->_virtualCount=$value;
163
+		if (($value = TPropertyValue::ensureInteger($value)) >= 0)
164
+			$this->_virtualCount = $value;
165 165
 		else
166 166
 			throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid');
167 167
 	}
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function getCount()
173 173
 	{
174
-		if($this->_dataSource===null)
174
+		if ($this->_dataSource === null)
175 175
 			return 0;
176
-		if(!$this->_allowPaging)
176
+		if (!$this->_allowPaging)
177 177
 			return $this->getDataSourceCount();
178
-		if(!$this->_allowCustomPaging && $this->getIsLastPage())
179
-			return $this->getDataSourceCount()-$this->getFirstIndexInPage();
178
+		if (!$this->_allowCustomPaging && $this->getIsLastPage())
179
+			return $this->getDataSourceCount() - $this->getFirstIndexInPage();
180 180
 		return $this->_pageSize;
181 181
 	}
182 182
 
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	public function getPageCount()
197 197
 	{
198
-		if($this->_dataSource===null)
198
+		if ($this->_dataSource === null)
199 199
 			return 0;
200
-		$count=$this->getDataSourceCount();
201
-		if(!$this->_allowPaging || $count<=0)
200
+		$count = $this->getDataSourceCount();
201
+		if (!$this->_allowPaging || $count <= 0)
202 202
 			return 1;
203
-		return (int)(($count+$this->_pageSize-1)/$this->_pageSize);
203
+		return (int) (($count + $this->_pageSize - 1) / $this->_pageSize);
204 204
 	}
205 205
 
206 206
 	/**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function getIsFirstPage()
210 210
 	{
211
-		if($this->_allowPaging)
212
-			return $this->_currentPageIndex===0;
211
+		if ($this->_allowPaging)
212
+			return $this->_currentPageIndex === 0;
213 213
 		else
214 214
 			return true;
215 215
 	}
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function getIsLastPage()
221 221
 	{
222
-		if($this->_allowPaging)
223
-			return $this->_currentPageIndex===$this->getPageCount()-1;
222
+		if ($this->_allowPaging)
223
+			return $this->_currentPageIndex === $this->getPageCount() - 1;
224 224
 		else
225 225
 			return true;
226 226
 	}
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	public function getFirstIndexInPage()
233 233
 	{
234
-		if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging)
235
-			return $this->_currentPageIndex*$this->_pageSize;
234
+		if ($this->_dataSource !== null && $this->_allowPaging && !$this->_allowCustomPaging)
235
+			return $this->_currentPageIndex * $this->_pageSize;
236 236
 		else
237 237
 			return 0;
238 238
 	}
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function getDataSourceCount()
244 244
 	{
245
-		if($this->_dataSource===null)
245
+		if ($this->_dataSource === null)
246 246
 			return 0;
247
-		else if($this->_allowCustomPaging)
247
+		else if ($this->_allowCustomPaging)
248 248
 			return $this->_virtualCount;
249 249
 		else
250 250
 			return $this->_dataSource->getCount();
@@ -255,10 +255,10 @@  discard block
 block discarded – undo
255 255
 	 */
256 256
 	public function getIterator()
257 257
 	{
258
-		if($this->_dataSource instanceof TList)
259
-			return new TPagedListIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount());
260
-		else if($this->_dataSource instanceof TMap)
261
-			return new TPagedMapIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount());
258
+		if ($this->_dataSource instanceof TList)
259
+			return new TPagedListIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
260
+		else if ($this->_dataSource instanceof TMap)
261
+			return new TPagedMapIterator($this->_dataSource, $this->getFirstIndexInPage(), $this->getCount());
262 262
 		else
263 263
 			return null;
264 264
 	}
@@ -291,15 +291,15 @@  discard block
 block discarded – undo
291 291
 	 * @param integer start index
292 292
 	 * @param integer number of items to be iterated through
293 293
 	 */
294
-	public function __construct(TList $list,$startIndex,$count)
294
+	public function __construct(TList $list, $startIndex, $count)
295 295
 	{
296
-		$this->_list=$list;
297
-		$this->_index=0;
298
-		$this->_startIndex=$startIndex;
299
-		if($startIndex+$count>$list->getCount())
300
-			$this->_count=$list->getCount()-$startIndex;
296
+		$this->_list = $list;
297
+		$this->_index = 0;
298
+		$this->_startIndex = $startIndex;
299
+		if ($startIndex + $count > $list->getCount())
300
+			$this->_count = $list->getCount() - $startIndex;
301 301
 		else
302
-			$this->_count=$count;
302
+			$this->_count = $count;
303 303
 	}
304 304
 
305 305
 	/**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 */
309 309
 	public function rewind()
310 310
 	{
311
-		$this->_index=0;
311
+		$this->_index = 0;
312 312
 	}
313 313
 
314 314
 	/**
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 */
329 329
 	public function current()
330 330
 	{
331
-		return $this->_list->itemAt($this->_startIndex+$this->_index);
331
+		return $this->_list->itemAt($this->_startIndex + $this->_index);
332 332
 	}
333 333
 
334 334
 	/**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 */
348 348
 	public function valid()
349 349
 	{
350
-		return $this->_index<$this->_count;
350
+		return $this->_index < $this->_count;
351 351
 	}
352 352
 }
353 353
 
@@ -375,16 +375,16 @@  discard block
 block discarded – undo
375 375
 	 * Constructor.
376 376
 	 * @param array the data to be iterated through
377 377
 	 */
378
-	public function __construct(TMap $map,$startIndex,$count)
378
+	public function __construct(TMap $map, $startIndex, $count)
379 379
 	{
380
-		$this->_map=$map;
381
-		$this->_index=0;
382
-		$this->_startIndex=$startIndex;
383
-		if($startIndex+$count>$map->getCount())
384
-			$this->_count=$map->getCount()-$startIndex;
380
+		$this->_map = $map;
381
+		$this->_index = 0;
382
+		$this->_startIndex = $startIndex;
383
+		if ($startIndex + $count > $map->getCount())
384
+			$this->_count = $map->getCount() - $startIndex;
385 385
 		else
386
-			$this->_count=$count;
387
-		$this->_iterator=$map->getIterator();
386
+			$this->_count = $count;
387
+		$this->_iterator = $map->getIterator();
388 388
 	}
389 389
 
390 390
 	/**
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 	public function rewind()
395 395
 	{
396 396
 		$this->_iterator->rewind();
397
-		for($i=0;$i<$this->_startIndex;++$i)
397
+		for ($i = 0; $i < $this->_startIndex; ++$i)
398 398
 			$this->_iterator->next();
399
-		$this->_index=0;
399
+		$this->_index = 0;
400 400
 	}
401 401
 
402 402
 	/**
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 */
437 437
 	public function valid()
438 438
 	{
439
-		return $this->_index<$this->_count;
439
+		return $this->_index < $this->_count;
440 440
 	}
441 441
 }
442 442
 
Please login to merge, or discard this patch.
Braces   +77 added lines, -60 removed lines patch added patch discarded remove patch
@@ -68,12 +68,13 @@  discard block
 block discarded – undo
68 68
 	{
69 69
 		if(!($value instanceof TMap) && !($value instanceof TList))
70 70
 		{
71
-			if(is_array($value))
72
-				$value=new TMap($value);
73
-			else if($value instanceof Traversable)
74
-				$value=new TList($value);
75
-			else if($value!==null)
76
-				throw new TInvalidDataTypeException('pageddatasource_datasource_invalid');
71
+			if(is_array($value)) {
72
+							$value=new TMap($value);
73
+			} else if($value instanceof Traversable) {
74
+							$value=new TList($value);
75
+			} else if($value!==null) {
76
+							throw new TInvalidDataTypeException('pageddatasource_datasource_invalid');
77
+			}
77 78
 		}
78 79
 		$this->_dataSource=$value;
79 80
 	}
@@ -91,10 +92,11 @@  discard block
 block discarded – undo
91 92
 	 */
92 93
 	public function setPageSize($value)
93 94
 	{
94
-		if(($value=TPropertyValue::ensureInteger($value))>0)
95
-			$this->_pageSize=$value;
96
-		else
97
-			throw new TInvalidDataValueException('pageddatasource_pagesize_invalid');
95
+		if(($value=TPropertyValue::ensureInteger($value))>0) {
96
+					$this->_pageSize=$value;
97
+		} else {
98
+					throw new TInvalidDataValueException('pageddatasource_pagesize_invalid');
99
+		}
98 100
 	}
99 101
 
100 102
 	/**
@@ -110,8 +112,9 @@  discard block
 block discarded – undo
110 112
 	 */
111 113
 	public function setCurrentPageIndex($value)
112 114
 	{
113
-		if(($value=TPropertyValue::ensureInteger($value))<0)
114
-			$value=0;
115
+		if(($value=TPropertyValue::ensureInteger($value))<0) {
116
+					$value=0;
117
+		}
115 118
 		$this->_currentPageIndex=$value;
116 119
 	}
117 120
 
@@ -160,10 +163,11 @@  discard block
 block discarded – undo
160 163
 	 */
161 164
 	public function setVirtualItemCount($value)
162 165
 	{
163
-		if(($value=TPropertyValue::ensureInteger($value))>=0)
164
-			$this->_virtualCount=$value;
165
-		else
166
-			throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid');
166
+		if(($value=TPropertyValue::ensureInteger($value))>=0) {
167
+					$this->_virtualCount=$value;
168
+		} else {
169
+					throw new TInvalidDataValueException('pageddatasource_virtualitemcount_invalid');
170
+		}
167 171
 	}
168 172
 
169 173
 	/**
@@ -171,12 +175,15 @@  discard block
 block discarded – undo
171 175
 	 */
172 176
 	public function getCount()
173 177
 	{
174
-		if($this->_dataSource===null)
175
-			return 0;
176
-		if(!$this->_allowPaging)
177
-			return $this->getDataSourceCount();
178
-		if(!$this->_allowCustomPaging && $this->getIsLastPage())
179
-			return $this->getDataSourceCount()-$this->getFirstIndexInPage();
178
+		if($this->_dataSource===null) {
179
+					return 0;
180
+		}
181
+		if(!$this->_allowPaging) {
182
+					return $this->getDataSourceCount();
183
+		}
184
+		if(!$this->_allowCustomPaging && $this->getIsLastPage()) {
185
+					return $this->getDataSourceCount()-$this->getFirstIndexInPage();
186
+		}
180 187
 		return $this->_pageSize;
181 188
 	}
182 189
 
@@ -195,11 +202,13 @@  discard block
 block discarded – undo
195 202
 	 */
196 203
 	public function getPageCount()
197 204
 	{
198
-		if($this->_dataSource===null)
199
-			return 0;
205
+		if($this->_dataSource===null) {
206
+					return 0;
207
+		}
200 208
 		$count=$this->getDataSourceCount();
201
-		if(!$this->_allowPaging || $count<=0)
202
-			return 1;
209
+		if(!$this->_allowPaging || $count<=0) {
210
+					return 1;
211
+		}
203 212
 		return (int)(($count+$this->_pageSize-1)/$this->_pageSize);
204 213
 	}
205 214
 
@@ -208,10 +217,11 @@  discard block
 block discarded – undo
208 217
 	 */
209 218
 	public function getIsFirstPage()
210 219
 	{
211
-		if($this->_allowPaging)
212
-			return $this->_currentPageIndex===0;
213
-		else
214
-			return true;
220
+		if($this->_allowPaging) {
221
+					return $this->_currentPageIndex===0;
222
+		} else {
223
+					return true;
224
+		}
215 225
 	}
216 226
 
217 227
 	/**
@@ -219,10 +229,11 @@  discard block
 block discarded – undo
219 229
 	 */
220 230
 	public function getIsLastPage()
221 231
 	{
222
-		if($this->_allowPaging)
223
-			return $this->_currentPageIndex===$this->getPageCount()-1;
224
-		else
225
-			return true;
232
+		if($this->_allowPaging) {
233
+					return $this->_currentPageIndex===$this->getPageCount()-1;
234
+		} else {
235
+					return true;
236
+		}
226 237
 	}
227 238
 
228 239
 	/**
@@ -231,10 +242,11 @@  discard block
 block discarded – undo
231 242
 	 */
232 243
 	public function getFirstIndexInPage()
233 244
 	{
234
-		if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging)
235
-			return $this->_currentPageIndex*$this->_pageSize;
236
-		else
237
-			return 0;
245
+		if($this->_dataSource!==null && $this->_allowPaging && !$this->_allowCustomPaging) {
246
+					return $this->_currentPageIndex*$this->_pageSize;
247
+		} else {
248
+					return 0;
249
+		}
238 250
 	}
239 251
 
240 252
 	/**
@@ -242,12 +254,13 @@  discard block
 block discarded – undo
242 254
 	 */
243 255
 	public function getDataSourceCount()
244 256
 	{
245
-		if($this->_dataSource===null)
246
-			return 0;
247
-		else if($this->_allowCustomPaging)
248
-			return $this->_virtualCount;
249
-		else
250
-			return $this->_dataSource->getCount();
257
+		if($this->_dataSource===null) {
258
+					return 0;
259
+		} else if($this->_allowCustomPaging) {
260
+					return $this->_virtualCount;
261
+		} else {
262
+					return $this->_dataSource->getCount();
263
+		}
251 264
 	}
252 265
 
253 266
 	/**
@@ -255,12 +268,13 @@  discard block
 block discarded – undo
255 268
 	 */
256 269
 	public function getIterator()
257 270
 	{
258
-		if($this->_dataSource instanceof TList)
259
-			return new TPagedListIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount());
260
-		else if($this->_dataSource instanceof TMap)
261
-			return new TPagedMapIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount());
262
-		else
263
-			return null;
271
+		if($this->_dataSource instanceof TList) {
272
+					return new TPagedListIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount());
273
+		} else if($this->_dataSource instanceof TMap) {
274
+					return new TPagedMapIterator($this->_dataSource,$this->getFirstIndexInPage(),$this->getCount());
275
+		} else {
276
+					return null;
277
+		}
264 278
 	}
265 279
 }
266 280
 
@@ -296,10 +310,11 @@  discard block
 block discarded – undo
296 310
 		$this->_list=$list;
297 311
 		$this->_index=0;
298 312
 		$this->_startIndex=$startIndex;
299
-		if($startIndex+$count>$list->getCount())
300
-			$this->_count=$list->getCount()-$startIndex;
301
-		else
302
-			$this->_count=$count;
313
+		if($startIndex+$count>$list->getCount()) {
314
+					$this->_count=$list->getCount()-$startIndex;
315
+		} else {
316
+					$this->_count=$count;
317
+		}
303 318
 	}
304 319
 
305 320
 	/**
@@ -380,10 +395,11 @@  discard block
 block discarded – undo
380 395
 		$this->_map=$map;
381 396
 		$this->_index=0;
382 397
 		$this->_startIndex=$startIndex;
383
-		if($startIndex+$count>$map->getCount())
384
-			$this->_count=$map->getCount()-$startIndex;
385
-		else
386
-			$this->_count=$count;
398
+		if($startIndex+$count>$map->getCount()) {
399
+					$this->_count=$map->getCount()-$startIndex;
400
+		} else {
401
+					$this->_count=$count;
402
+		}
387 403
 		$this->_iterator=$map->getIterator();
388 404
 	}
389 405
 
@@ -394,8 +410,9 @@  discard block
 block discarded – undo
394 410
 	public function rewind()
395 411
 	{
396 412
 		$this->_iterator->rewind();
397
-		for($i=0;$i<$this->_startIndex;++$i)
398
-			$this->_iterator->next();
413
+		for($i=0;$i<$this->_startIndex;++$i) {
414
+					$this->_iterator->next();
415
+		}
399 416
 		$this->_index=0;
400 417
 	}
401 418
 
Please login to merge, or discard this patch.
framework/Collections/TPagedList.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -76,6 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * Constructor.
77 77
 	 * @param array|Iterator the initial data. Default is null, meaning no initialization.
78 78
 	 * @param boolean whether the list is read-only. Always true for paged list.
79
+	 * @param integer[] $data
79 80
 	 */
80 81
 	public function __construct($data=null,$readOnly=false)
81 82
 	{
@@ -92,6 +93,7 @@  discard block
 block discarded – undo
92 93
 
93 94
 	/**
94 95
 	 * @param boolean whether to allow custom paging
96
+	 * @param boolean $value
95 97
 	 */
96 98
 	public function setCustomPaging($value)
97 99
 	{
@@ -139,6 +141,7 @@  discard block
 block discarded – undo
139 141
 	 * Raises <b>OnPageIndexChanged</b> event.
140 142
 	 * This event is raised each time when the list changes to a different page.
141 143
 	 * @param TPagedListPageChangedEventParameter event parameter
144
+	 * @param TPagedListPageChangedEventParameter|null $param
142 145
 	 */
143 146
 	public function onPageIndexChanged($param)
144 147
 	{
@@ -151,6 +154,7 @@  discard block
 block discarded – undo
151 154
 	 * and needs the new page of data. This event can only be raised when
152 155
 	 * {@link setCustomPaging CustomPaging} is true.
153 156
 	 * @param TPagedListFetchDataEventParameter event parameter
157
+	 * @param TPagedListFetchDataEventParameter $param
154 158
 	 */
155 159
 	public function onFetchData($param)
156 160
 	{
@@ -316,6 +320,7 @@  discard block
 block discarded – undo
316 320
 
317 321
 	/**
318 322
 	 * @param mixed the item
323
+	 * @param integer $item
319 324
 	 * @return integer the index of the item in the list (0 based), -1 if not found.
320 325
 	 */
321 326
 	public function indexOf($item)
@@ -380,6 +385,7 @@  discard block
 block discarded – undo
380 385
 	/**
381 386
 	 * Constructor.
382 387
 	 * @param integer old page index
388
+	 * @param integer $oldPage
383 389
 	 */
384 390
 	public function __construct($oldPage)
385 391
 	{
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -58,28 +58,28 @@  discard block
 block discarded – undo
58 58
 	/**
59 59
 	 * @var boolean whether to allow custom paging
60 60
 	 */
61
-	private $_customPaging=false;
61
+	private $_customPaging = false;
62 62
 	/**
63 63
 	 * @var integer number of items in each page
64 64
 	 */
65
-	private $_pageSize=10;
65
+	private $_pageSize = 10;
66 66
 	/**
67 67
 	 * @var integer current page index
68 68
 	 */
69
-	private $_currentPageIndex=-1;
69
+	private $_currentPageIndex = -1;
70 70
 	/**
71 71
 	 * @var integer user-assigned number of items in data source
72 72
 	 */
73
-	private $_virtualCount=-1;
73
+	private $_virtualCount = -1;
74 74
 
75 75
 	/**
76 76
 	 * Constructor.
77 77
 	 * @param array|Iterator the initial data. Default is null, meaning no initialization.
78 78
 	 * @param boolean whether the list is read-only. Always true for paged list.
79 79
 	 */
80
-	public function __construct($data=null,$readOnly=false)
80
+	public function __construct($data = null, $readOnly = false)
81 81
 	{
82
-		parent::__construct($data,true);
82
+		parent::__construct($data, true);
83 83
 	}
84 84
 
85 85
 	/**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function setCustomPaging($value)
97 97
 	{
98
-		$this->_customPaging=TPropertyValue::ensureBoolean($value);
98
+		$this->_customPaging = TPropertyValue::ensureBoolean($value);
99 99
 	}
100 100
 
101 101
 	/**
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function setPageSize($value)
113 113
 	{
114
-		if(($value=TPropertyValue::ensureInteger($value))>0)
115
-			$this->_pageSize=$value;
114
+		if (($value = TPropertyValue::ensureInteger($value)) > 0)
115
+			$this->_pageSize = $value;
116 116
 		else
117 117
 			throw new TInvalidDataValueException('pagedlist_pagesize_invalid');
118 118
 	}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function setCurrentPageIndex($value)
133 133
 	{
134
-		if($this->gotoPage($value=TPropertyValue::ensureInteger($value))===false)
134
+		if ($this->gotoPage($value = TPropertyValue::ensureInteger($value)) === false)
135 135
 			throw new TInvalidDataValueException('pagedlist_currentpageindex_invalid');
136 136
 	}
137 137
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	public function onPageIndexChanged($param)
144 144
 	{
145
-		$this->raiseEvent('OnPageIndexChanged',$this,$param);
145
+		$this->raiseEvent('OnPageIndexChanged', $this, $param);
146 146
 	}
147 147
 
148 148
 	/**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public function onFetchData($param)
156 156
 	{
157
-		$this->raiseEvent('OnFetchData',$this,$param);
157
+		$this->raiseEvent('OnFetchData', $this, $param);
158 158
 	}
159 159
 
160 160
 	/**
@@ -164,21 +164,21 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function gotoPage($pageIndex)
166 166
 	{
167
-		if($pageIndex===$this->_currentPageIndex)
167
+		if ($pageIndex === $this->_currentPageIndex)
168 168
 			return $pageIndex;
169
-		if($this->_customPaging)
169
+		if ($this->_customPaging)
170 170
 		{
171
-			if($pageIndex>=0 && ($this->_virtualCount<0 || $pageIndex<$this->getPageCount()))
171
+			if ($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount()))
172 172
 			{
173
-				$param=new TPagedListFetchDataEventParameter($pageIndex,$this->_pageSize*$pageIndex,$this->_pageSize);
173
+				$param = new TPagedListFetchDataEventParameter($pageIndex, $this->_pageSize * $pageIndex, $this->_pageSize);
174 174
 				$this->onFetchData($param);
175
-				if(($data=$param->getData())!==null)
175
+				if (($data = $param->getData()) !== null)
176 176
 				{
177 177
 					$this->setReadOnly(false);
178 178
 					$this->copyFrom($data);
179 179
 					$this->setReadOnly(true);
180
-					$oldPage=$this->_currentPageIndex;
181
-					$this->_currentPageIndex=$pageIndex;
180
+					$oldPage = $this->_currentPageIndex;
181
+					$this->_currentPageIndex = $pageIndex;
182 182
 					$this->onPageIndexChanged(new TPagedListPageChangedEventParameter($oldPage));
183 183
 					return $pageIndex;
184 184
 				}
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
 		}
191 191
 		else
192 192
 		{
193
-			if($pageIndex>=0 && $pageIndex<$this->getPageCount())
193
+			if ($pageIndex >= 0 && $pageIndex < $this->getPageCount())
194 194
 			{
195
-				$this->_currentPageIndex=$pageIndex;
195
+				$this->_currentPageIndex = $pageIndex;
196 196
 				$this->onPageIndexChanged(null);
197 197
 				return $pageIndex;
198 198
 			}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	public function nextPage()
209 209
 	{
210
-		return $this->gotoPage($this->_currentPageIndex+1);
210
+		return $this->gotoPage($this->_currentPageIndex + 1);
211 211
 	}
212 212
 
213 213
 	/**
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	public function previousPage()
218 218
 	{
219
-		return $this->gotoPage($this->_currentPageIndex-1);
219
+		return $this->gotoPage($this->_currentPageIndex - 1);
220 220
 	}
221 221
 
222 222
 	/**
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 	 */
233 233
 	public function setVirtualCount($value)
234 234
 	{
235
-		if(($value=TPropertyValue::ensureInteger($value))<0)
236
-			$value=-1;
237
-		$this->_virtualCount=$value;
235
+		if (($value = TPropertyValue::ensureInteger($value)) < 0)
236
+			$value = -1;
237
+		$this->_virtualCount = $value;
238 238
 	}
239 239
 
240 240
 	/**
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function getPageCount()
244 244
 	{
245
-		if($this->_customPaging)
245
+		if ($this->_customPaging)
246 246
 		{
247
-			if($this->_virtualCount>=0)
248
-				return (int)(($this->_virtualCount+$this->_pageSize-1)/$this->_pageSize);
247
+			if ($this->_virtualCount >= 0)
248
+				return (int) (($this->_virtualCount + $this->_pageSize - 1) / $this->_pageSize);
249 249
 			else
250 250
 				return -1;
251 251
 		}
252 252
 		else
253
-			return (int)((parent::getCount()+$this->_pageSize-1)/$this->_pageSize);
253
+			return (int) ((parent::getCount() + $this->_pageSize - 1) / $this->_pageSize);
254 254
 	}
255 255
 
256 256
 	/**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	public function getIsFirstPage()
260 260
 	{
261
-		return $this->_currentPageIndex===0;
261
+		return $this->_currentPageIndex === 0;
262 262
 	}
263 263
 
264 264
 	/**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	public function getIsLastPage()
268 268
 	{
269
-		return $this->_currentPageIndex===$this->getPageCount()-1;
269
+		return $this->_currentPageIndex === $this->getPageCount() - 1;
270 270
 	}
271 271
 
272 272
 	/**
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	 */
275 275
 	public function getCount()
276 276
 	{
277
-		if($this->_customPaging)
277
+		if ($this->_customPaging)
278 278
 			return parent::getCount();
279 279
 		else
280 280
 		{
281
-			if($this->_currentPageIndex===$this->getPageCount()-1)
282
-				return parent::getCount()-$this->_pageSize*$this->_currentPageIndex;
281
+			if ($this->_currentPageIndex === $this->getPageCount() - 1)
282
+				return parent::getCount() - $this->_pageSize * $this->_currentPageIndex;
283 283
 			else
284 284
 				return $this->_pageSize;
285 285
 		}
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	public function getIterator()
292 292
 	{
293
-		if($this->_customPaging)
293
+		if ($this->_customPaging)
294 294
 			return parent::getIterator();
295 295
 		else
296 296
 		{
297
-			$data=$this->toArray();
297
+			$data = $this->toArray();
298 298
 			return new TListIterator($data);
299 299
 		}
300 300
 	}
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 	 */
309 309
 	public function itemAt($index)
310 310
 	{
311
-		if($this->_customPaging)
311
+		if ($this->_customPaging)
312 312
 			return parent::itemAt($index);
313 313
 		else
314
-			return parent::itemAt($this->_pageSize*$this->_currentPageIndex+$index);
314
+			return parent::itemAt($this->_pageSize * $this->_currentPageIndex + $index);
315 315
 	}
316 316
 
317 317
 	/**
@@ -320,9 +320,9 @@  discard block
 block discarded – undo
320 320
 	 */
321 321
 	public function indexOf($item)
322 322
 	{
323
-		$c=$this->getCount();
324
-		for($i=0;$i<$c;++$i)
325
-			if($this->itemAt($i)===$item)
323
+		$c = $this->getCount();
324
+		for ($i = 0; $i < $c; ++$i)
325
+			if ($this->itemAt($i) === $item)
326 326
 				return $i;
327 327
 		return -1;
328 328
 	}
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 	 */
336 336
 	public function offsetExists($offset)
337 337
 	{
338
-		return ($offset>=0 && $offset<$this->getCount());
338
+		return ($offset >= 0 && $offset < $this->getCount());
339 339
 	}
340 340
 
341 341
 	/**
@@ -355,10 +355,10 @@  discard block
 block discarded – undo
355 355
 	 */
356 356
 	public function toArray()
357 357
 	{
358
-		$c=$this->getCount();
359
-		$array=array();
360
-		for($i=0;$i<$c;++$i)
361
-			$array[$i]=$this->itemAt($i);
358
+		$c = $this->getCount();
359
+		$array = array();
360
+		for ($i = 0; $i < $c; ++$i)
361
+			$array[$i] = $this->itemAt($i);
362 362
 		return $array;
363 363
 	}
364 364
 }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	public function __construct($oldPage)
385 385
 	{
386
-		$this->_oldPage=$oldPage;
386
+		$this->_oldPage = $oldPage;
387 387
 	}
388 388
 
389 389
 	/**
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	private $_pageIndex;
416 416
 	private $_offset;
417 417
 	private $_limit;
418
-	private $_data=null;
418
+	private $_data = null;
419 419
 
420 420
 	/**
421 421
 	 * Constructor.
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
 	 * @param integer offset of the first item in the new page
424 424
 	 * @param integer number of items in the new page desired
425 425
 	 */
426
-	public function __construct($pageIndex,$offset,$limit)
426
+	public function __construct($pageIndex, $offset, $limit)
427 427
 	{
428
-		$this->_pageIndex=$pageIndex;
429
-		$this->_offset=$offset;
430
-		$this->_limit=$limit;
428
+		$this->_pageIndex = $pageIndex;
429
+		$this->_offset = $offset;
430
+		$this->_limit = $limit;
431 431
 	}
432 432
 
433 433
 	/**
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	public function setData($value)
469 469
 	{
470
-		$this->_data=$value;
470
+		$this->_data = $value;
471 471
 	}
472 472
 }
473 473
 
Please login to merge, or discard this patch.
Braces   +50 added lines, -42 removed lines patch added patch discarded remove patch
@@ -111,10 +111,11 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function setPageSize($value)
113 113
 	{
114
-		if(($value=TPropertyValue::ensureInteger($value))>0)
115
-			$this->_pageSize=$value;
116
-		else
117
-			throw new TInvalidDataValueException('pagedlist_pagesize_invalid');
114
+		if(($value=TPropertyValue::ensureInteger($value))>0) {
115
+					$this->_pageSize=$value;
116
+		} else {
117
+					throw new TInvalidDataValueException('pagedlist_pagesize_invalid');
118
+		}
118 119
 	}
119 120
 
120 121
 	/**
@@ -131,8 +132,9 @@  discard block
 block discarded – undo
131 132
 	 */
132 133
 	public function setCurrentPageIndex($value)
133 134
 	{
134
-		if($this->gotoPage($value=TPropertyValue::ensureInteger($value))===false)
135
-			throw new TInvalidDataValueException('pagedlist_currentpageindex_invalid');
135
+		if($this->gotoPage($value=TPropertyValue::ensureInteger($value))===false) {
136
+					throw new TInvalidDataValueException('pagedlist_currentpageindex_invalid');
137
+		}
136 138
 	}
137 139
 
138 140
 	/**
@@ -164,8 +166,9 @@  discard block
 block discarded – undo
164 166
 	 */
165 167
 	public function gotoPage($pageIndex)
166 168
 	{
167
-		if($pageIndex===$this->_currentPageIndex)
168
-			return $pageIndex;
169
+		if($pageIndex===$this->_currentPageIndex) {
170
+					return $pageIndex;
171
+		}
169 172
 		if($this->_customPaging)
170 173
 		{
171 174
 			if($pageIndex>=0 && ($this->_virtualCount<0 || $pageIndex<$this->getPageCount()))
@@ -181,23 +184,22 @@  discard block
 block discarded – undo
181 184
 					$this->_currentPageIndex=$pageIndex;
182 185
 					$this->onPageIndexChanged(new TPagedListPageChangedEventParameter($oldPage));
183 186
 					return $pageIndex;
187
+				} else {
188
+									return false;
184 189
 				}
185
-				else
186
-					return false;
190
+			} else {
191
+							return false;
187 192
 			}
188
-			else
189
-				return false;
190
-		}
191
-		else
193
+		} else
192 194
 		{
193 195
 			if($pageIndex>=0 && $pageIndex<$this->getPageCount())
194 196
 			{
195 197
 				$this->_currentPageIndex=$pageIndex;
196 198
 				$this->onPageIndexChanged(null);
197 199
 				return $pageIndex;
200
+			} else {
201
+							return false;
198 202
 			}
199
-			else
200
-				return false;
201 203
 		}
202 204
 	}
203 205
 
@@ -232,8 +234,9 @@  discard block
 block discarded – undo
232 234
 	 */
233 235
 	public function setVirtualCount($value)
234 236
 	{
235
-		if(($value=TPropertyValue::ensureInteger($value))<0)
236
-			$value=-1;
237
+		if(($value=TPropertyValue::ensureInteger($value))<0) {
238
+					$value=-1;
239
+		}
237 240
 		$this->_virtualCount=$value;
238 241
 	}
239 242
 
@@ -244,13 +247,14 @@  discard block
 block discarded – undo
244 247
 	{
245 248
 		if($this->_customPaging)
246 249
 		{
247
-			if($this->_virtualCount>=0)
248
-				return (int)(($this->_virtualCount+$this->_pageSize-1)/$this->_pageSize);
249
-			else
250
-				return -1;
250
+			if($this->_virtualCount>=0) {
251
+							return (int)(($this->_virtualCount+$this->_pageSize-1)/$this->_pageSize);
252
+			} else {
253
+							return -1;
254
+			}
255
+		} else {
256
+					return (int)((parent::getCount()+$this->_pageSize-1)/$this->_pageSize);
251 257
 		}
252
-		else
253
-			return (int)((parent::getCount()+$this->_pageSize-1)/$this->_pageSize);
254 258
 	}
255 259
 
256 260
 	/**
@@ -274,14 +278,15 @@  discard block
 block discarded – undo
274 278
 	 */
275 279
 	public function getCount()
276 280
 	{
277
-		if($this->_customPaging)
278
-			return parent::getCount();
279
-		else
281
+		if($this->_customPaging) {
282
+					return parent::getCount();
283
+		} else
280 284
 		{
281
-			if($this->_currentPageIndex===$this->getPageCount()-1)
282
-				return parent::getCount()-$this->_pageSize*$this->_currentPageIndex;
283
-			else
284
-				return $this->_pageSize;
285
+			if($this->_currentPageIndex===$this->getPageCount()-1) {
286
+							return parent::getCount()-$this->_pageSize*$this->_currentPageIndex;
287
+			} else {
288
+							return $this->_pageSize;
289
+			}
285 290
 		}
286 291
 	}
287 292
 
@@ -290,9 +295,9 @@  discard block
 block discarded – undo
290 295
 	 */
291 296
 	public function getIterator()
292 297
 	{
293
-		if($this->_customPaging)
294
-			return parent::getIterator();
295
-		else
298
+		if($this->_customPaging) {
299
+					return parent::getIterator();
300
+		} else
296 301
 		{
297 302
 			$data=$this->toArray();
298 303
 			return new TListIterator($data);
@@ -308,10 +313,11 @@  discard block
 block discarded – undo
308 313
 	 */
309 314
 	public function itemAt($index)
310 315
 	{
311
-		if($this->_customPaging)
312
-			return parent::itemAt($index);
313
-		else
314
-			return parent::itemAt($this->_pageSize*$this->_currentPageIndex+$index);
316
+		if($this->_customPaging) {
317
+					return parent::itemAt($index);
318
+		} else {
319
+					return parent::itemAt($this->_pageSize*$this->_currentPageIndex+$index);
320
+		}
315 321
 	}
316 322
 
317 323
 	/**
@@ -321,9 +327,10 @@  discard block
 block discarded – undo
321 327
 	public function indexOf($item)
322 328
 	{
323 329
 		$c=$this->getCount();
324
-		for($i=0;$i<$c;++$i)
325
-			if($this->itemAt($i)===$item)
330
+		for($i=0;$i<$c;++$i) {
331
+					if($this->itemAt($i)===$item)
326 332
 				return $i;
333
+		}
327 334
 		return -1;
328 335
 	}
329 336
 
@@ -357,8 +364,9 @@  discard block
 block discarded – undo
357 364
 	{
358 365
 		$c=$this->getCount();
359 366
 		$array=array();
360
-		for($i=0;$i<$c;++$i)
361
-			$array[$i]=$this->itemAt($i);
367
+		for($i=0;$i<$c;++$i) {
368
+					$array[$i]=$this->itemAt($i);
369
+		}
362 370
 		return $array;
363 371
 	}
364 372
 }
Please login to merge, or discard this patch.