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