Completed
Push — namespace2 ( 791eac...5c23fb )
by Fabio
08:41
created

TSax3_StateParser   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 280
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 14

Importance

Changes 0
Metric Value
dl 0
loc 280
rs 10
c 0
b 0
f 0
wmc 20
lcom 1
cbo 14

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A unscanCharacter() 0 3 1
A ignoreCharacter() 0 3 1
A scanCharacter() 0 5 2
A scanUntilString() 0 8 2
A scanUntilCharacters() 0 1 1
A ignoreWhitespace() 0 1 1
C parse() 0 58 8
A _parse() 0 6 3
1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
//
4
// +----------------------------------------------------------------------+
5
// | PHP Version 4                                                        |
6
// +----------------------------------------------------------------------+
7
// | Copyright (c) 1997-2002 The PHP Group                                |
8
// +----------------------------------------------------------------------+
9
// | This source file is subject to version 2.02 of the PHP license,      |
10
// | that is bundled with this package in the file LICENSE, and is        |
11
// | available at through the world-wide-web at                           |
12
// | http://www.php.net/license/3_0.txt.                                  |
13
// | If you did not receive a copy of the PHP license and are unable to   |
14
// | obtain it through the world-wide-web, please send a note to          |
15
// | [email protected] so we can mail you a copy immediately.               |
16
// +----------------------------------------------------------------------+
17
// | Authors: Alexander Zhukov <[email protected]> Original port from Python |
18
// | Authors: Harry Fuecks <[email protected]> Port to PEAR + more  |
19
// | Authors: Many @ Sitepointforums Advanced PHP Forums                  |
20
// +----------------------------------------------------------------------+
21
//
22
// $Id: HTMLSax3.php 3188 2012-07-12 12:13:23Z ctrlaltca $
23
//
24
/**
25
* Main parser components
26
* @package    System.Security.SafeHtml
27
*/
28
29
namespace Prado\Vendor\SafeHtml\HTMLSax3;
30
31
/**
32
* Required classes
33
*/
34
require_once(dirname(__FILE__).'/States.php');
35
require_once(dirname(__FILE__).'/Decorators.php');
36
37
/**
38
* Base State Parser
39
* @package System.Security.SafeHtml
40
* @access protected
41
* @abstract
42
*/
43
class TSax3_StateParser {
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
44
    /**
45
    * Instance of user front end class to be passed to callbacks
46
    * @var TSax3
47
    * @access private
48
    */
49
    public $htmlsax;
50
    /**
51
    * User defined object for handling elements
52
    * @var object
53
    * @access private
54
    */
55
    public $handler_object_element;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $handler_object_element exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
56
    /**
57
    * User defined open tag handler method
58
    * @var string
59
    * @access private
60
    */
61
    public $handler_method_opening;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $handler_method_opening exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
62
    /**
63
    * User defined close tag handler method
64
    * @var string
65
    * @access private
66
    */
67
    public $handler_method_closing;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $handler_method_closing exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
68
    /**
69
    * User defined object for handling data in elements
70
    * @var object
71
    * @access private
72
    */
73
    public $handler_object_data;
74
    /**
75
    * User defined data handler method
76
    * @var string
77
    * @access private
78
    */
79
    public $handler_method_data;
80
    /**
81
    * User defined object for handling processing instructions
82
    * @var object
83
    * @access private
84
    */
85
    public $handler_object_pi;
86
    /**
87
    * User defined processing instruction handler method
88
    * @var string
89
    * @access private
90
    */
91
    public $handler_method_pi;
92
    /**
93
    * User defined object for handling JSP/ASP tags
94
    * @var object
95
    * @access private
96
    */
97
    public $handler_object_jasp;
98
    /**
99
    * User defined JSP/ASP handler method
100
    * @var string
101
    * @access private
102
    */
103
    public $handler_method_jasp;
104
    /**
105
    * User defined object for handling XML escapes
106
    * @var object
107
    * @access private
108
    */
109
    public $handler_object_escape;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $handler_object_escape exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
110
    /**
111
    * User defined XML escape handler method
112
    * @var string
113
    * @access private
114
    */
115
    public $handler_method_escape;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $handler_method_escape exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
116
    /**
117
    * User defined handler object or NullHandler
118
    * @var object
119
    * @access private
120
    */
121
    public $handler_default;
122
    /**
123
    * Parser options determining parsing behavior
124
    * @var array
125
    * @access private
126
    */
127
    protected $parser_options = array();
128
    /**
129
    * XML document being parsed
130
    * @var string
131
    * @access private
132
    */
133
    protected $rawtext;
134
    /**
135
    * Position in XML document relative to start (0)
136
    * @var int
137
    * @access private
138
    */
139
    protected $position;
140
    /**
141
    * Length of the XML document in characters
142
    * @var int
143
    * @access private
144
    */
145
    protected $length;
146
    /**
147
    * Array of state objects
148
    * @var array
149
    * @access private
150
    */
151
    protected $State = array();
152
153
	const TSAX3_STATE_STOP = 0;
154
	const TSAX3_STATE_START = 1;
155
	const TSAX3_STATE_TAG = 2;
156
	const TSAX3_STATE_OPENING_TAG = 3;
157
	const TSAX3_STATE_CLOSING_TAG = 4;
158
	const TSAX3_STATE_ESCAPE = 6;
159
	const TSAX3_STATE_JASP = 7;
160
	const TSAX3_STATE_PI = 8;
161
162
    /**
163
    * Constructs TSax3_StateParser setting up states
164
    * @var TSax3 instance of user front end class
165
    * @access protected
166
    */
167
    protected function __construct($htmlsax) {
168
        $this->htmlsax = $htmlsax;
169
        $this->State[self::TSAX3_STATE_START] = new TSax3_StartingState();
170
171
        $this->State[self::TSAX3_STATE_CLOSING_TAG] = new TSax3_ClosingTagState();
172
        $this->State[self::TSAX3_STATE_TAG] = new TSax3_TagState();
173
        $this->State[self::TSAX3_STATE_OPENING_TAG] = new TSax3_OpeningTagState();
174
175
        $this->State[self::TSAX3_STATE_PI] = new TSax3_PiState();
176
        $this->State[self::TSAX3_STATE_JASP] = new TSax3_JaspState();
177
        $this->State[self::TSAX3_STATE_ESCAPE] = new TSax3_EscapeState();
178
    }
179
180
    /**
181
    * Moves the position back one character
182
    * @access protected
183
    * @return void
184
    */
185
    function unscanCharacter() {
186
        $this->position -= 1;
187
    }
188
189
    /**
190
    * Moves the position forward one character
191
    * @access protected
192
    * @return void
193
    */
194
    function ignoreCharacter() {
195
        $this->position += 1;
196
    }
197
198
    /**
199
    * Returns the next character from the XML document or void if at end
200
    * @access protected
201
    * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string|null.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
202
    */
203
    function scanCharacter() {
204
        if ($this->position < $this->length) {
205
            return $this->rawtext{$this->position++};
206
        }
207
    }
208
209
    /**
210
    * Returns a string from the current position to the next occurance
211
    * of the supplied string
212
    * @param string string to search until
213
    * @access protected
214
    * @return string
215
    */
216
    function scanUntilString($string) {
217
        $start = $this->position;
218
        $this->position = strpos($this->rawtext, $string, $start);
219
        if ($this->position === FALSE) {
220
            $this->position = $this->length;
221
        }
222
        return substr($this->rawtext, $start, $this->position - $start);
223
    }
224
225
    /**
226
    * Returns a string from the current position until the first instance of
227
    * one of the characters in the supplied string argument
228
    * @param string string to search until
229
    * @access protected
230
    * @return string
231
    * @abstract
232
    */
233
    function scanUntilCharacters($string) {}
234
235
    /**
236
    * Moves the position forward past any whitespace characters
237
    * @access protected
238
    * @return void
239
    * @abstract
240
    */
241
    function ignoreWhitespace() {}
242
243
    /**
244
    * Begins the parsing operation, setting up any decorators, depending on
245
    * parse options invoking _parse() to execute parsing
246
    * @param string XML document to parse
247
    * @access protected
248
    * @return void
249
    */
250
    function parse($data) {
251
        if ($this->parser_options['XML_OPTION_TRIM_DATA_NODES']==1) {
252
            $decorator = new TSax3_Trim(
253
                $this->handler_object_data,
254
                $this->handler_method_data);
255
            $this->handler_object_data =& $decorator;
256
            $this->handler_method_data = 'trimData';
257
        }
258
        if ($this->parser_options['XML_OPTION_CASE_FOLDING']==1) {
259
            $open_decor = new TSax3_CaseFolding(
260
                $this->handler_object_element,
261
                $this->handler_method_opening,
262
                $this->handler_method_closing);
263
            $this->handler_object_element =& $open_decor;
264
            $this->handler_method_opening ='foldOpen';
265
            $this->handler_method_closing ='foldClose';
266
        }
267
        if ($this->parser_options['XML_OPTION_LINEFEED_BREAK']==1) {
268
            $decorator = new TSax3_Linefeed(
269
                $this->handler_object_data,
270
                $this->handler_method_data);
271
            $this->handler_object_data =& $decorator;
272
            $this->handler_method_data = 'breakData';
273
        }
274
        if ($this->parser_options['XML_OPTION_TAB_BREAK']==1) {
275
            $decorator = new TSax3_Tab(
276
                $this->handler_object_data,
277
                $this->handler_method_data);
278
            $this->handler_object_data =& $decorator;
279
            $this->handler_method_data = 'breakData';
280
        }
281
        if ($this->parser_options['XML_OPTION_ENTITIES_UNPARSED']==1) {
282
            $decorator = new TSax3_Entities_Unparsed(
283
                $this->handler_object_data,
284
                $this->handler_method_data);
285
            $this->handler_object_data =& $decorator;
286
            $this->handler_method_data = 'breakData';
287
        }
288
        if ($this->parser_options['XML_OPTION_ENTITIES_PARSED']==1) {
289
            $decorator = new TSax3_Entities_Parsed(
290
                $this->handler_object_data,
291
                $this->handler_method_data);
292
            $this->handler_object_data =& $decorator;
293
            $this->handler_method_data = 'breakData';
294
        }
295
        // Note switched on by default
296
        if ($this->parser_options['XML_OPTION_STRIP_ESCAPES']==1) {
297
            $decorator = new TSax3_Escape_Stripper(
298
                $this->handler_object_escape,
299
                $this->handler_method_escape);
300
            $this->handler_object_escape =& $decorator;
301
            $this->handler_method_escape = 'strip';
302
        }
303
        $this->rawtext = $data;
304
        $this->length = strlen($data);
305
        $this->position = 0;
306
        $this->_parse();
307
    }
308
309
    /**
310
    * Performs the parsing itself, delegating calls to a specific parser
311
    * state
312
    * @param constant state object to parse with
313
    * @access protected
314
    * @return void
315
    */
316
    function _parse($state = self::TSAX3_STATE_START) {
317
        do {
318
            $state = $this->State[$state]->parse($this);
319
        } while ($state != self::TSAX3_STATE_STOP &&
320
                    $this->position < $this->length);
321
    }
322
}
323
324
/**
325
* Parser for PHP Versions below 4.3.0. Uses a slower parsing mechanism than
326
* the equivalent PHP 4.3.0+  subclass of StateParser
327
* @package System.Security.SafeHtml
328
* @access protected
329
* @see TSax3_StateParser_Gtet430
330
*/
331
class TSax3_StateParser_Lt430 extends TSax3_StateParser {
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
332
    /**
333
    * Constructs TSax3_StateParser_Lt430 defining available
334
    * parser options
335
    * @var TSax3 instance of user front end class
336
    * @access protected
337
    */
338
    function __construct(& $htmlsax) {
339
        parent::__construct($htmlsax);
340
        $this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
341
        $this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
342
        $this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
343
        $this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
344
        $this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
345
        $this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
346
        $this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
347
		//var_dump($this->parser_options);
348
    }
349
350
    /**
351
    * Returns a string from the current position until the first instance of
352
    * one of the characters in the supplied string argument
353
    * @param string string to search until
354
    * @access protected
355
    * @return string
356
    */
357
    function scanUntilCharacters($string) {
358
        $startpos = $this->position;
359
        while ($this->position < $this->length && strpos($string, $this->rawtext{$this->position}) === FALSE) {
360
            $this->position++;
361
        }
362
        return substr($this->rawtext, $startpos, $this->position - $startpos);
363
    }
364
365
    /**
366
    * Moves the position forward past any whitespace characters
367
    * @access protected
368
    * @return void
369
    */
370
    function ignoreWhitespace() {
371
        while ($this->position < $this->length &&
372
            strpos(" \n\r\t", $this->rawtext{$this->position}) !== FALSE) {
373
            $this->position++;
374
        }
375
    }
376
377
    /**
378
    * Begins the parsing operation, setting up the unparsed XML entities
379
    * decorator if necessary then delegating further work to parent
380
    * @param string XML document to parse
381
    * @access protected
382
    * @return void
383
    */
384
    function parse($data) {
385
        parent::parse($data);
386
    }
387
}
388
389
/**
390
* Parser for PHP Versions equal to or greater than 4.3.0. Uses a faster
391
* parsing mechanism than the equivalent PHP < 4.3.0 subclass of StateParser
392
* @package System.Security.SafeHtml
393
* @access protected
394
* @see TSax3_StateParser_Lt430
395
*/
396
class TSax3_StateParser_Gtet430 extends TSax3_StateParser {
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
397
    /**
398
    * Constructs TSax3_StateParser_Gtet430 defining available
399
    * parser options
400
    * @var TSax3 instance of user front end class
401
    * @access protected
402
    */
403
    function __construct(& $htmlsax) {
404
        parent::__construct($htmlsax);
405
        $this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
406
        $this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
407
        $this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
408
        $this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
409
        $this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
410
        $this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
411
        $this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
412
    }
413
    /**
414
    * Returns a string from the current position until the first instance of
415
    * one of the characters in the supplied string argument.
416
    * @param string string to search until
417
    * @access protected
418
    * @return string
419
    */
420
    function scanUntilCharacters($string) {
421
        $startpos = $this->position;
422
        $length = strcspn($this->rawtext, $string, $startpos);
423
        $this->position += $length;
424
        return substr($this->rawtext, $startpos, $length);
425
    }
426
427
    /**
428
    * Moves the position forward past any whitespace characters
429
    * @access protected
430
    * @return void
431
    */
432
    function ignoreWhitespace() {
433
        $this->position += strspn($this->rawtext, " \n\r\t", $this->position);
434
    }
435
436
    /**
437
    * Begins the parsing operation, setting up the parsed and unparsed
438
    * XML entity decorators if necessary then delegating further work
439
    * to parent
440
    * @param string XML document to parse
441
    * @access protected
442
    * @return void
443
    */
444
    function parse($data) {
445
        parent::parse($data);
446
    }
447
}
448
449
/**
450
* Default NullHandler for methods which were not set by user
451
* @package System.Security.SafeHtml
452
* @access protected
453
*/
454
class TSax3_NullHandler {
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
455
    /**
456
    * Generic handler method which does nothing
457
    * @access protected
458
    * @return void
459
    */
460
    function DoNothing() {
461
    }
462
}
463
464
/**
465
* User interface class. All user calls should only be made to this class
466
* @package System.Security.SafeHtml
467
* @access public
468
*/
469
class TSax3 {
470
    /**
471
    * Instance of concrete subclass of TSax3_StateParser
472
    * @var TSax3_StateParser
473
    * @access private
474
    */
475
    private $state_parser;
476
477
    /**
478
    * Constructs TSax3 selecting concrete StateParser subclass
479
    * depending on PHP version being used as well as setting the default
480
    * NullHandler for all callbacks<br />
481
    * <b>Example:</b>
482
    * <pre>
483
    * $myHandler = & new MyHandler();
484
    * $parser = new TSax3();
485
    * $parser->set_object($myHandler);
486
    * $parser->set_option('XML_OPTION_CASE_FOLDING');
487
    * $parser->set_element_handler('myOpenHandler','myCloseHandler');
488
    * $parser->set_data_handler('myDataHandler');
489
    * $parser->parser($xml);
490
    * </pre>
491
    * @access public
492
    */
493
    function __construct() {
494
        if (version_compare(phpversion(), '4.3', 'ge')) {
495
            $this->state_parser = new TSax3_StateParser_Gtet430($this);
496
        } else {
497
            $this->state_parser = new TSax3_StateParser_Lt430($this);
498
        }
499
        $nullhandler = new TSax3_NullHandler();
500
        $this->set_object($nullhandler);
501
        $this->set_element_handler('DoNothing', 'DoNothing');
502
        $this->set_data_handler('DoNothing');
503
        $this->set_pi_handler('DoNothing');
504
        $this->set_jasp_handler('DoNothing');
505
        $this->set_escape_handler('DoNothing');
506
    }
507
508
    /**
509
    * Sets the user defined handler object. Returns a PEAR Error
510
    * if supplied argument is not an object.
511
    * @param object handler object containing SAX callback methods
512
    * @access public
513
    * @return mixed
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use boolean|null.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
514
    */
515
    function set_object(&$object) {
516
        if ( is_object($object) ) {
517
            $this->state_parser->handler_default =& $object;
518
            return true;
519
        } else {
520
            require_once('PEAR.php');
521
            PEAR::raiseError('TSax3::set_object requires '.
522
                'an object instance');
523
        }
524
    }
525
526
    /**
527
    * Sets a parser option. By default all options are switched off.
528
    * Returns a PEAR Error if option is invalid<br />
529
    * <b>Available options:</b>
530
    * <ul>
531
    * <li>XML_OPTION_TRIM_DATA_NODES: trim whitespace off the beginning
532
    * and end of data passed to the data handler</li>
533
    * <li>XML_OPTION_LINEFEED_BREAK: linefeeds result in additional data
534
    * handler calls</li>
535
    * <li>XML_OPTION_TAB_BREAK: tabs result in additional data handler
536
    * calls</li>
537
    * <li>XML_OPTION_ENTITIES_UNPARSED: XML entities are returned as
538
    * seperate data handler calls in unparsed form</li>
539
    * <li>XML_OPTION_ENTITIES_PARSED: (PHP 4.3.0+ only) XML entities are
540
    * returned as seperate data handler calls and are parsed with
541
    * PHP's html_entity_decode() function</li>
542
    * <li>XML_OPTION_STRIP_ESCAPES: strips out the -- -- comment markers
543
    * or CDATA markup inside an XML escape, if found.</li>
544
    * </ul>
545
    * To get HTMLSax to behave in the same way as the native PHP SAX parser,
546
    * using it's default state, you need to switch on XML_OPTION_LINEFEED_BREAK,
547
    * XML_OPTION_ENTITIES_PARSED and XML_OPTION_CASE_FOLDING
548
    * @param string name of parser option
549
    * @param int (optional) 1 to switch on, 0 for off
550
    * @access public
551
    * @return boolean
552
    */
553
    function set_option($name, $value=1) {
554
        if ( array_key_exists($name,$this->state_parser->parser_options) ) {
0 ignored issues
show
Bug introduced by
The property parser_options cannot be accessed from this context as it is declared protected in class Prado\Vendor\SafeHtml\HTMLSax3\TSax3_StateParser.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
555
            $this->state_parser->parser_options[$name] = $value;
0 ignored issues
show
Bug introduced by
The property parser_options cannot be accessed from this context as it is declared protected in class Prado\Vendor\SafeHtml\HTMLSax3\TSax3_StateParser.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
556
            return true;
557
        } else {
558
            require_once('PEAR.php');
559
            PEAR::raiseError('TSax3::set_option('.$name.') illegal');
560
        }
561
    }
562
563
    /**
564
    * Sets the data handler method which deals with the contents of XML
565
    * elements.<br />
566
    * The handler method must accept two arguments, the first being an
567
    * instance of TSax3 and the second being the contents of an
568
    * XML element e.g.
569
    * <pre>
570
    * function myDataHander(& $parser,$data){}
571
    * </pre>
572
    * @param string name of method
573
    * @access public
574
    * @return void
575
    * @see set_object
576
    */
577
    function set_data_handler($data_method) {
0 ignored issues
show
Coding Style Naming introduced by
The parameter $data_method is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
578
        $this->state_parser->handler_object_data =& $this->state_parser->handler_default;
579
        $this->state_parser->handler_method_data = $data_method;
580
    }
581
582
    /**
583
    * Sets the open and close tag handlers
584
    * <br />The open handler method must accept three arguments; the parser,
585
    * the tag name and an array of attributes e.g.
586
    * <pre>
587
    * function myOpenHander(& $parser,$tagname,$attrs=array()){}
588
    * </pre>
589
    * The close handler method must accept two arguments; the parser and
590
    * the tag name e.g.
591
    * <pre>
592
    * function myCloseHander(& $parser,$tagname){}
593
    * </pre>
594
    * @param string name of open method
595
    * @param string name of close method
596
    * @access public
597
    * @return void
598
    * @see set_object
599
    */
600
    function set_element_handler($opening_method, $closing_method) {
0 ignored issues
show
Coding Style Naming introduced by
The parameter $opening_method is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style Naming introduced by
The parameter $closing_method is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
601
        $this->state_parser->handler_object_element =& $this->state_parser->handler_default;
602
        $this->state_parser->handler_method_opening = $opening_method;
603
        $this->state_parser->handler_method_closing = $closing_method;
604
    }
605
606
    /**
607
    * Sets the processing instruction handler method e.g. for PHP open
608
    * and close tags<br />
609
    * The handler method must accept three arguments; the parser, the
610
    * PI target and data inside the PI
611
    * <pre>
612
    * function myPIHander(& $parser,$target, $data){}
613
    * </pre>
614
    * @param string name of method
615
    * @access public
616
    * @return void
617
    * @see set_object
618
    */
619
    function set_pi_handler($pi_method) {
0 ignored issues
show
Coding Style Naming introduced by
The parameter $pi_method is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
620
        $this->state_parser->handler_object_pi =& $this->state_parser->handler_default;
621
        $this->state_parser->handler_method_pi = $pi_method;
622
    }
623
624
    /**
625
    * Sets the XML escape handler method e.g. for comments and doctype
626
    * declarations<br />
627
    * The handler method must accept two arguments; the parser and the
628
    * contents of the escaped section
629
    * <pre>
630
    * function myEscapeHander(& $parser, $data){}
631
    * </pre>
632
    * @param string name of method
633
    * @access public
634
    * @return void
635
    * @see set_object
636
    */
637
    function set_escape_handler($escape_method) {
0 ignored issues
show
Coding Style Naming introduced by
The parameter $escape_method is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
638
        $this->state_parser->handler_object_escape =& $this->state_parser->handler_default;
639
        $this->state_parser->handler_method_escape = $escape_method;
640
    }
641
642
    /**
643
    * Sets the JSP/ASP markup handler<br />
644
    * The handler method must accept two arguments; the parser and
645
    * body of the JASP tag
646
    * <pre>
647
    * function myJaspHander(& $parser, $data){}
648
    * </pre>
649
    * @param string name of method
650
    * @access public
651
    * @return void
652
    * @see set_object
653
    */
654
    function set_jasp_handler ($jasp_method) {
0 ignored issues
show
Coding Style Naming introduced by
The parameter $jasp_method is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
655
        $this->state_parser->handler_object_jasp =& $this->state_parser->handler_default;
656
        $this->state_parser->handler_method_jasp = $jasp_method;
657
    }
658
659
    /**
660
    * Returns the current string position of the "cursor" inside the XML
661
    * document
662
    * <br />Intended for use from within a user defined handler called
663
    * via the $parser reference e.g.
664
    * <pre>
665
    * function myDataHandler(& $parser,$data) {
666
    *     echo( 'Current position: '.$parser->get_current_position() );
667
    * }
668
    * </pre>
669
    * @access public
670
    * @return int
671
    * @see get_length
672
    */
673
    function get_current_position() {
674
        return $this->state_parser->position;
0 ignored issues
show
Bug introduced by
The property position cannot be accessed from this context as it is declared protected in class Prado\Vendor\SafeHtml\HTMLSax3\TSax3_StateParser.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
675
    }
676
677
    /**
678
    * Returns the string length of the XML document being parsed
679
    * @access public
680
    * @return int
681
    */
682
    function get_length() {
683
        return $this->state_parser->length;
0 ignored issues
show
Bug introduced by
The property length cannot be accessed from this context as it is declared protected in class Prado\Vendor\SafeHtml\HTMLSax3\TSax3_StateParser.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
684
    }
685
686
    /**
687
    * Start parsing some XML
688
    * @param string XML document
689
    * @access public
690
    * @return void
691
    */
692
    function parse($data) {
693
        $this->state_parser->parse($data);
694
    }
695
}
696