1 | <?php |
||
23 | abstract class AbstractSaxHandler implements SaxHandlerInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $options; |
||
29 | |||
30 | /** |
||
31 | * @var string|null |
||
32 | */ |
||
33 | private $currentElement = null; |
||
34 | |||
35 | /** |
||
36 | * @var int |
||
37 | */ |
||
38 | private $stackSize = 0; |
||
39 | |||
40 | /** |
||
41 | * @var string|null |
||
42 | */ |
||
43 | private $dataBuffer = null; |
||
44 | |||
45 | /** |
||
46 | * AbstractSaxHandler constructor. |
||
47 | * |
||
48 | * @param array $options |
||
49 | */ |
||
50 | 7 | public function __construct(array $options = array()) |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 6 | final public function parse(StreamInterface $stream) |
|
100 | |||
101 | /** |
||
102 | * Document start handler, executed when parsing process started. |
||
103 | * |
||
104 | * @param resource $parser Parser handler. |
||
105 | * @param StreamInterface $stream XML stream. |
||
106 | */ |
||
107 | abstract protected function onDocumentStart($parser, $stream); |
||
108 | |||
109 | /** |
||
110 | * Element start handler, executed when XML tag is entered. |
||
111 | * |
||
112 | * @param resource $parser Parser handler. |
||
113 | * @param string $name Tag name. |
||
114 | * @param array $attributes Element attributes. |
||
115 | */ |
||
116 | abstract protected function onElementStart($parser, $name, $attributes); |
||
117 | |||
118 | /** |
||
119 | * Element CDATA handler, executed when XML tag CDATA is parsed. |
||
120 | * |
||
121 | * @param resource $parser Parser handler. |
||
122 | * @param string $data Element CDATA. |
||
123 | */ |
||
124 | abstract protected function onElementData($parser, $data); |
||
125 | |||
126 | /** |
||
127 | * Element end handler, executed when XML tag is leaved. |
||
128 | * |
||
129 | * @param resource $parser Parser handler. |
||
130 | * @param string $name Tag name. |
||
131 | */ |
||
132 | abstract protected function onElementEnd($parser, $name); |
||
133 | |||
134 | /** |
||
135 | * Document end handler, executed when parsing process ended. |
||
136 | * |
||
137 | * @param resource $parser Parser handler. |
||
138 | * @param StreamInterface $stream XML stream. |
||
139 | */ |
||
140 | abstract protected function onDocumentEnd($parser, $stream); |
||
141 | |||
142 | /** |
||
143 | * Start namespace declaration handler, executed when namespace declaration started. |
||
144 | * |
||
145 | * @param resource $parser Parser handler. |
||
146 | * @param string $prefix Namespace reference within an XML object. |
||
147 | * @param string $uri Uniform Resource Identifier (URI) of namespace. |
||
148 | */ |
||
149 | protected function onNamespaceDeclarationStart($parser, $prefix, $uri) |
||
153 | |||
154 | /** |
||
155 | * End namespace declaration handler, executed when namespace declaration ended. |
||
156 | * |
||
157 | * @param resource $parser Parser handler. |
||
158 | * @param string $prefix Namespace reference within an XML object. |
||
159 | */ |
||
160 | protected function onNamespaceDeclarationEnd($parser , string $prefix) |
||
164 | |||
165 | /** |
||
166 | * Parsing error handler. |
||
167 | * |
||
168 | * @param string $message Parsing error message. |
||
169 | * @param int $code Error code. |
||
170 | * @param int $lineno XML line number which caused error. |
||
171 | */ |
||
172 | abstract protected function onParseError($message, $code, $lineno); |
||
173 | |||
174 | /** |
||
175 | * Get parsing result. |
||
176 | * |
||
177 | * Considering that your handler processed XML document, this method will collect |
||
178 | * parsing result. This method is called last and it will provide parsing result to invoker. |
||
179 | * |
||
180 | * @return mixed Parsing result |
||
181 | */ |
||
182 | abstract protected function getResult(); |
||
183 | |||
184 | /** |
||
185 | * Parse path to XML document/string content. |
||
186 | * |
||
187 | * @param resource $parser Parser. |
||
188 | * @param StreamInterface $stream XML document stream. |
||
189 | * @return AbstractSaxHandler $this Fluent interface. |
||
190 | * |
||
191 | * @throws \RuntimeException |
||
192 | */ |
||
193 | 6 | private function process($parser, StreamInterface $stream) |
|
205 | |||
206 | /** |
||
207 | * Attach handlers. |
||
208 | * |
||
209 | * @param resource $parser XML parser. |
||
210 | * @return AbstractSaxHandler $this Fluent interface. |
||
211 | */ |
||
212 | private function attachHandlers($parser) |
||
260 | } |
||
261 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.