@@ -57,9 +57,9 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
57
57
58
58
private $ defaultContext = [
59
59
self ::AS_COLLECTION => false ,
60
- self ::DECODER_IGNORED_NODE_TYPES => [XML_PI_NODE , XML_COMMENT_NODE ],
60
+ self ::DECODER_IGNORED_NODE_TYPES => [\ XML_PI_NODE , \ XML_COMMENT_NODE ],
61
61
self ::ENCODER_IGNORED_NODE_TYPES => [],
62
- self ::LOAD_OPTIONS => LIBXML_NONET | LIBXML_NOBLANKS ,
62
+ self ::LOAD_OPTIONS => \ LIBXML_NONET | \ LIBXML_NOBLANKS ,
63
63
self ::REMOVE_EMPTY_TAGS => false ,
64
64
self ::ROOT_NODE_NAME => 'response ' ,
65
65
self ::TYPE_CAST_ATTRIBUTES => true ,
@@ -83,7 +83,7 @@ public function __construct(array $defaultContext = [])
83
83
public function encode ($ data , string $ format , array $ context = [])
84
84
{
85
85
$ encoderIgnoredNodeTypes = $ context [self ::ENCODER_IGNORED_NODE_TYPES ] ?? $ this ->defaultContext [self ::ENCODER_IGNORED_NODE_TYPES ];
86
- $ ignorePiNode = \in_array (XML_PI_NODE , $ encoderIgnoredNodeTypes , true );
86
+ $ ignorePiNode = \in_array (\ XML_PI_NODE , $ encoderIgnoredNodeTypes , true );
87
87
if ($ data instanceof \DOMDocument) {
88
88
return $ data ->saveXML ($ ignorePiNode ? $ data ->documentElement : null );
89
89
}
@@ -115,7 +115,7 @@ public function decode(string $data, string $format, array $context = [])
115
115
}
116
116
117
117
$ internalErrors = libxml_use_internal_errors (true );
118
- if (LIBXML_VERSION < 20900 ) {
118
+ if (\ LIBXML_VERSION < 20900 ) {
119
119
$ disableEntities = libxml_disable_entity_loader (true );
120
120
}
121
121
libxml_clear_errors ();
@@ -124,7 +124,7 @@ public function decode(string $data, string $format, array $context = [])
124
124
$ dom ->loadXML ($ data , $ context [self ::LOAD_OPTIONS ] ?? $ this ->defaultContext [self ::LOAD_OPTIONS ]);
125
125
126
126
libxml_use_internal_errors ($ internalErrors );
127
- if (LIBXML_VERSION < 20900 ) {
127
+ if (\ LIBXML_VERSION < 20900 ) {
128
128
libxml_disable_entity_loader ($ disableEntities );
129
129
}
130
130
@@ -137,7 +137,7 @@ public function decode(string $data, string $format, array $context = [])
137
137
$ rootNode = null ;
138
138
$ decoderIgnoredNodeTypes = $ context [self ::DECODER_IGNORED_NODE_TYPES ] ?? $ this ->defaultContext [self ::DECODER_IGNORED_NODE_TYPES ];
139
139
foreach ($ dom ->childNodes as $ child ) {
140
- if (XML_DOCUMENT_TYPE_NODE === $ child ->nodeType ) {
140
+ if (\ XML_DOCUMENT_TYPE_NODE === $ child ->nodeType ) {
141
141
throw new NotEncodableValueException ('Document types are not allowed. ' );
142
142
}
143
143
if (!$ rootNode && !\in_array ($ child ->nodeType , $ decoderIgnoredNodeTypes , true )) {
@@ -307,7 +307,7 @@ private function parseXmlAttributes(\DOMNode $node, array $context = []): array
307
307
continue ;
308
308
}
309
309
310
- if (false !== $ val = filter_var ($ attr ->nodeValue , FILTER_VALIDATE_INT )) {
310
+ if (false !== $ val = filter_var ($ attr ->nodeValue , \ FILTER_VALIDATE_INT )) {
311
311
$ data ['@ ' .$ attr ->nodeName ] = $ val ;
312
312
313
313
continue ;
@@ -330,7 +330,7 @@ private function parseXmlValue(\DOMNode $node, array $context = [])
330
330
return $ node ->nodeValue ;
331
331
}
332
332
333
- if (1 === $ node ->childNodes ->length && \in_array ($ node ->firstChild ->nodeType , [XML_TEXT_NODE , XML_CDATA_SECTION_NODE ])) {
333
+ if (1 === $ node ->childNodes ->length && \in_array ($ node ->firstChild ->nodeType , [\ XML_TEXT_NODE , \ XML_CDATA_SECTION_NODE ])) {
334
334
return $ node ->firstChild ->nodeValue ;
335
335
}
336
336
@@ -384,7 +384,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
384
384
} elseif ('# ' === $ key ) {
385
385
$ append = $ this ->selectNodeType ($ parentNode , $ data );
386
386
} elseif ('#comment ' === $ key ) {
387
- if (!\in_array (XML_COMMENT_NODE , $ encoderIgnoredNodeTypes , true )) {
387
+ if (!\in_array (\ XML_COMMENT_NODE , $ encoderIgnoredNodeTypes , true )) {
388
388
$ append = $ this ->appendComment ($ parentNode , $ data );
389
389
}
390
390
} elseif (\is_array ($ data ) && false === is_numeric ($ key )) {
0 commit comments