PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.6
Kubio AI Page Builder v2.8.6
2.9.0 2.8.6 2.8.5 2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / vendor / symfony / var-dumper / Caster / DOMCaster.php
kubio / vendor / symfony / var-dumper / Caster Last commit date
AmqpCaster.php 1 year ago ArgsStub.php 1 year ago Caster.php 1 year ago ClassStub.php 1 year ago ConstStub.php 4 years ago CutArrayStub.php 4 years ago CutStub.php 4 years ago DOMCaster.php 1 year ago DateCaster.php 1 year ago DoctrineCaster.php 1 year ago DsCaster.php 1 year ago DsPairStub.php 4 years ago EnumStub.php 4 years ago ExceptionCaster.php 1 year ago FiberCaster.php 1 year ago FrameStub.php 4 years ago GmpCaster.php 1 year ago ImagineCaster.php 4 years ago ImgStub.php 1 year ago IntlCaster.php 1 year ago LinkStub.php 1 year ago MemcachedCaster.php 1 year ago MysqliCaster.php 1 year ago PdoCaster.php 1 year ago PgSqlCaster.php 1 year ago ProxyManagerCaster.php 1 year ago RdKafkaCaster.php 1 year ago RedisCaster.php 1 year ago ReflectionCaster.php 1 year ago ResourceCaster.php 1 year ago SplCaster.php 1 year ago StubCaster.php 1 year ago SymfonyCaster.php 1 year ago TraceStub.php 1 year ago UuidCaster.php 4 years ago XmlReaderCaster.php 1 year ago XmlResourceCaster.php 1 year ago
DOMCaster.php
298 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\VarDumper\Caster;
13
14 use Symfony\Component\VarDumper\Cloner\Stub;
15
16 /**
17 * Casts DOM related classes to array representation.
18 *
19 * @author Nicolas Grekas <p@tchwork.com>
20 *
21 * @final
22 */
23 class DOMCaster
24 {
25 private const ERROR_CODES = [
26 0 => 'DOM_PHP_ERR',
27 \DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR',
28 \DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR',
29 \DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR',
30 \DOM_WRONG_DOCUMENT_ERR => 'DOM_WRONG_DOCUMENT_ERR',
31 \DOM_INVALID_CHARACTER_ERR => 'DOM_INVALID_CHARACTER_ERR',
32 \DOM_NO_DATA_ALLOWED_ERR => 'DOM_NO_DATA_ALLOWED_ERR',
33 \DOM_NO_MODIFICATION_ALLOWED_ERR => 'DOM_NO_MODIFICATION_ALLOWED_ERR',
34 \DOM_NOT_FOUND_ERR => 'DOM_NOT_FOUND_ERR',
35 \DOM_NOT_SUPPORTED_ERR => 'DOM_NOT_SUPPORTED_ERR',
36 \DOM_INUSE_ATTRIBUTE_ERR => 'DOM_INUSE_ATTRIBUTE_ERR',
37 \DOM_INVALID_STATE_ERR => 'DOM_INVALID_STATE_ERR',
38 \DOM_SYNTAX_ERR => 'DOM_SYNTAX_ERR',
39 \DOM_INVALID_MODIFICATION_ERR => 'DOM_INVALID_MODIFICATION_ERR',
40 \DOM_NAMESPACE_ERR => 'DOM_NAMESPACE_ERR',
41 \DOM_INVALID_ACCESS_ERR => 'DOM_INVALID_ACCESS_ERR',
42 \DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR',
43 ];
44
45 private const NODE_TYPES = [
46 \XML_ELEMENT_NODE => 'XML_ELEMENT_NODE',
47 \XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE',
48 \XML_TEXT_NODE => 'XML_TEXT_NODE',
49 \XML_CDATA_SECTION_NODE => 'XML_CDATA_SECTION_NODE',
50 \XML_ENTITY_REF_NODE => 'XML_ENTITY_REF_NODE',
51 \XML_ENTITY_NODE => 'XML_ENTITY_NODE',
52 \XML_PI_NODE => 'XML_PI_NODE',
53 \XML_COMMENT_NODE => 'XML_COMMENT_NODE',
54 \XML_DOCUMENT_NODE => 'XML_DOCUMENT_NODE',
55 \XML_DOCUMENT_TYPE_NODE => 'XML_DOCUMENT_TYPE_NODE',
56 \XML_DOCUMENT_FRAG_NODE => 'XML_DOCUMENT_FRAG_NODE',
57 \XML_NOTATION_NODE => 'XML_NOTATION_NODE',
58 \XML_HTML_DOCUMENT_NODE => 'XML_HTML_DOCUMENT_NODE',
59 \XML_DTD_NODE => 'XML_DTD_NODE',
60 \XML_ELEMENT_DECL_NODE => 'XML_ELEMENT_DECL_NODE',
61 \XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE',
62 \XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE',
63 \XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE',
64 ];
65
66 public static function castException(\DOMException $e, array $a, Stub $stub, bool $isNested)
67 {
68 $k = Caster::PREFIX_PROTECTED.'code';
69 if (isset($a[$k], self::ERROR_CODES[$a[$k]])) {
70 $a[$k] = new ConstStub(self::ERROR_CODES[$a[$k]], $a[$k]);
71 }
72
73 return $a;
74 }
75
76 public static function castLength($dom, array $a, Stub $stub, bool $isNested)
77 {
78 $a += [
79 'length' => $dom->length,
80 ];
81
82 return $a;
83 }
84
85 public static function castImplementation(\DOMImplementation $dom, array $a, Stub $stub, bool $isNested)
86 {
87 $a += [
88 Caster::PREFIX_VIRTUAL.'Core' => '1.0',
89 Caster::PREFIX_VIRTUAL.'XML' => '2.0',
90 ];
91
92 return $a;
93 }
94
95 public static function castNode(\DOMNode $dom, array $a, Stub $stub, bool $isNested)
96 {
97 $a += [
98 'nodeName' => $dom->nodeName,
99 'nodeValue' => new CutStub($dom->nodeValue),
100 'nodeType' => new ConstStub(self::NODE_TYPES[$dom->nodeType], $dom->nodeType),
101 'parentNode' => new CutStub($dom->parentNode),
102 'childNodes' => $dom->childNodes,
103 'firstChild' => new CutStub($dom->firstChild),
104 'lastChild' => new CutStub($dom->lastChild),
105 'previousSibling' => new CutStub($dom->previousSibling),
106 'nextSibling' => new CutStub($dom->nextSibling),
107 'attributes' => $dom->attributes,
108 'ownerDocument' => new CutStub($dom->ownerDocument),
109 'namespaceURI' => $dom->namespaceURI,
110 'prefix' => $dom->prefix,
111 'localName' => $dom->localName,
112 'baseURI' => $dom->baseURI ? new LinkStub($dom->baseURI) : $dom->baseURI,
113 'textContent' => new CutStub($dom->textContent),
114 ];
115
116 return $a;
117 }
118
119 public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, bool $isNested)
120 {
121 $a += [
122 'nodeName' => $dom->nodeName,
123 'nodeValue' => new CutStub($dom->nodeValue),
124 'nodeType' => new ConstStub(self::NODE_TYPES[$dom->nodeType], $dom->nodeType),
125 'prefix' => $dom->prefix,
126 'localName' => $dom->localName,
127 'namespaceURI' => $dom->namespaceURI,
128 'ownerDocument' => new CutStub($dom->ownerDocument),
129 'parentNode' => new CutStub($dom->parentNode),
130 ];
131
132 return $a;
133 }
134
135 public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, bool $isNested, int $filter = 0)
136 {
137 $a += [
138 'doctype' => $dom->doctype,
139 'implementation' => $dom->implementation,
140 'documentElement' => new CutStub($dom->documentElement),
141 'encoding' => $dom->encoding,
142 'xmlEncoding' => $dom->xmlEncoding,
143 'xmlStandalone' => $dom->xmlStandalone,
144 'xmlVersion' => $dom->xmlVersion,
145 'strictErrorChecking' => $dom->strictErrorChecking,
146 'documentURI' => $dom->documentURI ? new LinkStub($dom->documentURI) : $dom->documentURI,
147 'formatOutput' => $dom->formatOutput,
148 'validateOnParse' => $dom->validateOnParse,
149 'resolveExternals' => $dom->resolveExternals,
150 'preserveWhiteSpace' => $dom->preserveWhiteSpace,
151 'recover' => $dom->recover,
152 'substituteEntities' => $dom->substituteEntities,
153 ];
154
155 if (!($filter & Caster::EXCLUDE_VERBOSE)) {
156 $formatOutput = $dom->formatOutput;
157 $dom->formatOutput = true;
158 $a += [Caster::PREFIX_VIRTUAL.'xml' => $dom->saveXML()];
159 $dom->formatOutput = $formatOutput;
160 }
161
162 return $a;
163 }
164
165 public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, bool $isNested)
166 {
167 $a += [
168 'data' => $dom->data,
169 'length' => $dom->length,
170 ];
171
172 return $a;
173 }
174
175 public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, bool $isNested)
176 {
177 $a += [
178 'name' => $dom->name,
179 'specified' => $dom->specified,
180 'value' => $dom->value,
181 'ownerElement' => $dom->ownerElement,
182 'schemaTypeInfo' => $dom->schemaTypeInfo,
183 ];
184
185 return $a;
186 }
187
188 public static function castElement(\DOMElement $dom, array $a, Stub $stub, bool $isNested)
189 {
190 $a += [
191 'tagName' => $dom->tagName,
192 'schemaTypeInfo' => $dom->schemaTypeInfo,
193 ];
194
195 return $a;
196 }
197
198 public static function castText(\DOMText $dom, array $a, Stub $stub, bool $isNested)
199 {
200 $a += [
201 'wholeText' => $dom->wholeText,
202 ];
203
204 return $a;
205 }
206
207 public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, bool $isNested)
208 {
209 $a += [
210 'typeName' => $dom->typeName,
211 'typeNamespace' => $dom->typeNamespace,
212 ];
213
214 return $a;
215 }
216
217 public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, bool $isNested)
218 {
219 $a += [
220 'severity' => $dom->severity,
221 'message' => $dom->message,
222 'type' => $dom->type,
223 'relatedException' => $dom->relatedException,
224 'related_data' => $dom->related_data,
225 'location' => $dom->location,
226 ];
227
228 return $a;
229 }
230
231 public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, bool $isNested)
232 {
233 $a += [
234 'lineNumber' => $dom->lineNumber,
235 'columnNumber' => $dom->columnNumber,
236 'offset' => $dom->offset,
237 'relatedNode' => $dom->relatedNode,
238 'uri' => $dom->uri ? new LinkStub($dom->uri, $dom->lineNumber) : $dom->uri,
239 ];
240
241 return $a;
242 }
243
244 public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, bool $isNested)
245 {
246 $a += [
247 'name' => $dom->name,
248 'entities' => $dom->entities,
249 'notations' => $dom->notations,
250 'publicId' => $dom->publicId,
251 'systemId' => $dom->systemId,
252 'internalSubset' => $dom->internalSubset,
253 ];
254
255 return $a;
256 }
257
258 public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, bool $isNested)
259 {
260 $a += [
261 'publicId' => $dom->publicId,
262 'systemId' => $dom->systemId,
263 ];
264
265 return $a;
266 }
267
268 public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, bool $isNested)
269 {
270 $a += [
271 'publicId' => $dom->publicId,
272 'systemId' => $dom->systemId,
273 'notationName' => $dom->notationName,
274 ];
275
276 return $a;
277 }
278
279 public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, bool $isNested)
280 {
281 $a += [
282 'target' => $dom->target,
283 'data' => $dom->data,
284 ];
285
286 return $a;
287 }
288
289 public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, bool $isNested)
290 {
291 $a += [
292 'document' => $dom->document,
293 ];
294
295 return $a;
296 }
297 }
298