comparison vendor/symfony/var-dumper/Caster/DOMCaster.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
18 * 18 *
19 * @author Nicolas Grekas <p@tchwork.com> 19 * @author Nicolas Grekas <p@tchwork.com>
20 */ 20 */
21 class DOMCaster 21 class DOMCaster
22 { 22 {
23 private static $errorCodes = array( 23 private static $errorCodes = [
24 DOM_PHP_ERR => 'DOM_PHP_ERR', 24 DOM_PHP_ERR => 'DOM_PHP_ERR',
25 DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR', 25 DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR',
26 DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR', 26 DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR',
27 DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR', 27 DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR',
28 DOM_WRONG_DOCUMENT_ERR => 'DOM_WRONG_DOCUMENT_ERR', 28 DOM_WRONG_DOCUMENT_ERR => 'DOM_WRONG_DOCUMENT_ERR',
36 DOM_SYNTAX_ERR => 'DOM_SYNTAX_ERR', 36 DOM_SYNTAX_ERR => 'DOM_SYNTAX_ERR',
37 DOM_INVALID_MODIFICATION_ERR => 'DOM_INVALID_MODIFICATION_ERR', 37 DOM_INVALID_MODIFICATION_ERR => 'DOM_INVALID_MODIFICATION_ERR',
38 DOM_NAMESPACE_ERR => 'DOM_NAMESPACE_ERR', 38 DOM_NAMESPACE_ERR => 'DOM_NAMESPACE_ERR',
39 DOM_INVALID_ACCESS_ERR => 'DOM_INVALID_ACCESS_ERR', 39 DOM_INVALID_ACCESS_ERR => 'DOM_INVALID_ACCESS_ERR',
40 DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR', 40 DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR',
41 ); 41 ];
42 42
43 private static $nodeTypes = array( 43 private static $nodeTypes = [
44 XML_ELEMENT_NODE => 'XML_ELEMENT_NODE', 44 XML_ELEMENT_NODE => 'XML_ELEMENT_NODE',
45 XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE', 45 XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE',
46 XML_TEXT_NODE => 'XML_TEXT_NODE', 46 XML_TEXT_NODE => 'XML_TEXT_NODE',
47 XML_CDATA_SECTION_NODE => 'XML_CDATA_SECTION_NODE', 47 XML_CDATA_SECTION_NODE => 'XML_CDATA_SECTION_NODE',
48 XML_ENTITY_REF_NODE => 'XML_ENTITY_REF_NODE', 48 XML_ENTITY_REF_NODE => 'XML_ENTITY_REF_NODE',
57 XML_DTD_NODE => 'XML_DTD_NODE', 57 XML_DTD_NODE => 'XML_DTD_NODE',
58 XML_ELEMENT_DECL_NODE => 'XML_ELEMENT_DECL_NODE', 58 XML_ELEMENT_DECL_NODE => 'XML_ELEMENT_DECL_NODE',
59 XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE', 59 XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE',
60 XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE', 60 XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE',
61 XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE', 61 XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE',
62 ); 62 ];
63 63
64 public static function castException(\DOMException $e, array $a, Stub $stub, $isNested) 64 public static function castException(\DOMException $e, array $a, Stub $stub, $isNested)
65 { 65 {
66 $k = Caster::PREFIX_PROTECTED.'code'; 66 $k = Caster::PREFIX_PROTECTED.'code';
67 if (isset($a[$k], self::$errorCodes[$a[$k]])) { 67 if (isset($a[$k], self::$errorCodes[$a[$k]])) {
71 return $a; 71 return $a;
72 } 72 }
73 73
74 public static function castLength($dom, array $a, Stub $stub, $isNested) 74 public static function castLength($dom, array $a, Stub $stub, $isNested)
75 { 75 {
76 $a += array( 76 $a += [
77 'length' => $dom->length, 77 'length' => $dom->length,
78 ); 78 ];
79 79
80 return $a; 80 return $a;
81 } 81 }
82 82
83 public static function castImplementation($dom, array $a, Stub $stub, $isNested) 83 public static function castImplementation($dom, array $a, Stub $stub, $isNested)
84 { 84 {
85 $a += array( 85 $a += [
86 Caster::PREFIX_VIRTUAL.'Core' => '1.0', 86 Caster::PREFIX_VIRTUAL.'Core' => '1.0',
87 Caster::PREFIX_VIRTUAL.'XML' => '2.0', 87 Caster::PREFIX_VIRTUAL.'XML' => '2.0',
88 ); 88 ];
89 89
90 return $a; 90 return $a;
91 } 91 }
92 92
93 public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested) 93 public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested)
94 { 94 {
95 $a += array( 95 $a += [
96 'nodeName' => $dom->nodeName, 96 'nodeName' => $dom->nodeName,
97 'nodeValue' => new CutStub($dom->nodeValue), 97 'nodeValue' => new CutStub($dom->nodeValue),
98 'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType), 98 'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
99 'parentNode' => new CutStub($dom->parentNode), 99 'parentNode' => new CutStub($dom->parentNode),
100 'childNodes' => $dom->childNodes, 100 'childNodes' => $dom->childNodes,
107 'namespaceURI' => $dom->namespaceURI, 107 'namespaceURI' => $dom->namespaceURI,
108 'prefix' => $dom->prefix, 108 'prefix' => $dom->prefix,
109 'localName' => $dom->localName, 109 'localName' => $dom->localName,
110 'baseURI' => $dom->baseURI ? new LinkStub($dom->baseURI) : $dom->baseURI, 110 'baseURI' => $dom->baseURI ? new LinkStub($dom->baseURI) : $dom->baseURI,
111 'textContent' => new CutStub($dom->textContent), 111 'textContent' => new CutStub($dom->textContent),
112 ); 112 ];
113 113
114 return $a; 114 return $a;
115 } 115 }
116 116
117 public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested) 117 public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested)
118 { 118 {
119 $a += array( 119 $a += [
120 'nodeName' => $dom->nodeName, 120 'nodeName' => $dom->nodeName,
121 'nodeValue' => new CutStub($dom->nodeValue), 121 'nodeValue' => new CutStub($dom->nodeValue),
122 'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType), 122 'nodeType' => new ConstStub(self::$nodeTypes[$dom->nodeType], $dom->nodeType),
123 'prefix' => $dom->prefix, 123 'prefix' => $dom->prefix,
124 'localName' => $dom->localName, 124 'localName' => $dom->localName,
125 'namespaceURI' => $dom->namespaceURI, 125 'namespaceURI' => $dom->namespaceURI,
126 'ownerDocument' => new CutStub($dom->ownerDocument), 126 'ownerDocument' => new CutStub($dom->ownerDocument),
127 'parentNode' => new CutStub($dom->parentNode), 127 'parentNode' => new CutStub($dom->parentNode),
128 ); 128 ];
129 129
130 return $a; 130 return $a;
131 } 131 }
132 132
133 public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested, $filter = 0) 133 public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested, $filter = 0)
134 { 134 {
135 $a += array( 135 $a += [
136 'doctype' => $dom->doctype, 136 'doctype' => $dom->doctype,
137 'implementation' => $dom->implementation, 137 'implementation' => $dom->implementation,
138 'documentElement' => new CutStub($dom->documentElement), 138 'documentElement' => new CutStub($dom->documentElement),
139 'actualEncoding' => $dom->actualEncoding, 139 'actualEncoding' => $dom->actualEncoding,
140 'encoding' => $dom->encoding, 140 'encoding' => $dom->encoding,
150 'validateOnParse' => $dom->validateOnParse, 150 'validateOnParse' => $dom->validateOnParse,
151 'resolveExternals' => $dom->resolveExternals, 151 'resolveExternals' => $dom->resolveExternals,
152 'preserveWhiteSpace' => $dom->preserveWhiteSpace, 152 'preserveWhiteSpace' => $dom->preserveWhiteSpace,
153 'recover' => $dom->recover, 153 'recover' => $dom->recover,
154 'substituteEntities' => $dom->substituteEntities, 154 'substituteEntities' => $dom->substituteEntities,
155 ); 155 ];
156 156
157 if (!($filter & Caster::EXCLUDE_VERBOSE)) { 157 if (!($filter & Caster::EXCLUDE_VERBOSE)) {
158 $formatOutput = $dom->formatOutput; 158 $formatOutput = $dom->formatOutput;
159 $dom->formatOutput = true; 159 $dom->formatOutput = true;
160 $a += array(Caster::PREFIX_VIRTUAL.'xml' => $dom->saveXML()); 160 $a += [Caster::PREFIX_VIRTUAL.'xml' => $dom->saveXML()];
161 $dom->formatOutput = $formatOutput; 161 $dom->formatOutput = $formatOutput;
162 } 162 }
163 163
164 return $a; 164 return $a;
165 } 165 }
166 166
167 public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, $isNested) 167 public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, $isNested)
168 { 168 {
169 $a += array( 169 $a += [
170 'data' => $dom->data, 170 'data' => $dom->data,
171 'length' => $dom->length, 171 'length' => $dom->length,
172 ); 172 ];
173 173
174 return $a; 174 return $a;
175 } 175 }
176 176
177 public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested) 177 public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested)
178 { 178 {
179 $a += array( 179 $a += [
180 'name' => $dom->name, 180 'name' => $dom->name,
181 'specified' => $dom->specified, 181 'specified' => $dom->specified,
182 'value' => $dom->value, 182 'value' => $dom->value,
183 'ownerElement' => $dom->ownerElement, 183 'ownerElement' => $dom->ownerElement,
184 'schemaTypeInfo' => $dom->schemaTypeInfo, 184 'schemaTypeInfo' => $dom->schemaTypeInfo,
185 ); 185 ];
186 186
187 return $a; 187 return $a;
188 } 188 }
189 189
190 public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNested) 190 public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNested)
191 { 191 {
192 $a += array( 192 $a += [
193 'tagName' => $dom->tagName, 193 'tagName' => $dom->tagName,
194 'schemaTypeInfo' => $dom->schemaTypeInfo, 194 'schemaTypeInfo' => $dom->schemaTypeInfo,
195 ); 195 ];
196 196
197 return $a; 197 return $a;
198 } 198 }
199 199
200 public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested) 200 public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested)
201 { 201 {
202 $a += array( 202 $a += [
203 'wholeText' => $dom->wholeText, 203 'wholeText' => $dom->wholeText,
204 ); 204 ];
205 205
206 return $a; 206 return $a;
207 } 207 }
208 208
209 public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $isNested) 209 public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $isNested)
210 { 210 {
211 $a += array( 211 $a += [
212 'typeName' => $dom->typeName, 212 'typeName' => $dom->typeName,
213 'typeNamespace' => $dom->typeNamespace, 213 'typeNamespace' => $dom->typeNamespace,
214 ); 214 ];
215 215
216 return $a; 216 return $a;
217 } 217 }
218 218
219 public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $isNested) 219 public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $isNested)
220 { 220 {
221 $a += array( 221 $a += [
222 'severity' => $dom->severity, 222 'severity' => $dom->severity,
223 'message' => $dom->message, 223 'message' => $dom->message,
224 'type' => $dom->type, 224 'type' => $dom->type,
225 'relatedException' => $dom->relatedException, 225 'relatedException' => $dom->relatedException,
226 'related_data' => $dom->related_data, 226 'related_data' => $dom->related_data,
227 'location' => $dom->location, 227 'location' => $dom->location,
228 ); 228 ];
229 229
230 return $a; 230 return $a;
231 } 231 }
232 232
233 public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNested) 233 public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNested)
234 { 234 {
235 $a += array( 235 $a += [
236 'lineNumber' => $dom->lineNumber, 236 'lineNumber' => $dom->lineNumber,
237 'columnNumber' => $dom->columnNumber, 237 'columnNumber' => $dom->columnNumber,
238 'offset' => $dom->offset, 238 'offset' => $dom->offset,
239 'relatedNode' => $dom->relatedNode, 239 'relatedNode' => $dom->relatedNode,
240 'uri' => $dom->uri ? new LinkStub($dom->uri, $dom->lineNumber) : $dom->uri, 240 'uri' => $dom->uri ? new LinkStub($dom->uri, $dom->lineNumber) : $dom->uri,
241 ); 241 ];
242 242
243 return $a; 243 return $a;
244 } 244 }
245 245
246 public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, $isNested) 246 public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, $isNested)
247 { 247 {
248 $a += array( 248 $a += [
249 'name' => $dom->name, 249 'name' => $dom->name,
250 'entities' => $dom->entities, 250 'entities' => $dom->entities,
251 'notations' => $dom->notations, 251 'notations' => $dom->notations,
252 'publicId' => $dom->publicId, 252 'publicId' => $dom->publicId,
253 'systemId' => $dom->systemId, 253 'systemId' => $dom->systemId,
254 'internalSubset' => $dom->internalSubset, 254 'internalSubset' => $dom->internalSubset,
255 ); 255 ];
256 256
257 return $a; 257 return $a;
258 } 258 }
259 259
260 public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $isNested) 260 public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $isNested)
261 { 261 {
262 $a += array( 262 $a += [
263 'publicId' => $dom->publicId, 263 'publicId' => $dom->publicId,
264 'systemId' => $dom->systemId, 264 'systemId' => $dom->systemId,
265 ); 265 ];
266 266
267 return $a; 267 return $a;
268 } 268 }
269 269
270 public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNested) 270 public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNested)
271 { 271 {
272 $a += array( 272 $a += [
273 'publicId' => $dom->publicId, 273 'publicId' => $dom->publicId,
274 'systemId' => $dom->systemId, 274 'systemId' => $dom->systemId,
275 'notationName' => $dom->notationName, 275 'notationName' => $dom->notationName,
276 'actualEncoding' => $dom->actualEncoding, 276 'actualEncoding' => $dom->actualEncoding,
277 'encoding' => $dom->encoding, 277 'encoding' => $dom->encoding,
278 'version' => $dom->version, 278 'version' => $dom->version,
279 ); 279 ];
280 280
281 return $a; 281 return $a;
282 } 282 }
283 283
284 public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, $isNested) 284 public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, $isNested)
285 { 285 {
286 $a += array( 286 $a += [
287 'target' => $dom->target, 287 'target' => $dom->target,
288 'data' => $dom->data, 288 'data' => $dom->data,
289 ); 289 ];
290 290
291 return $a; 291 return $a;
292 } 292 }
293 293
294 public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, $isNested) 294 public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, $isNested)
295 { 295 {
296 $a += array( 296 $a += [
297 'document' => $dom->document, 297 'document' => $dom->document,
298 ); 298 ];
299 299
300 return $a; 300 return $a;
301 } 301 }
302 } 302 }