Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #27926 [Serializer] XmlEncoder doesn't ignore PI nodes while …
…encoding (maidmaid) This PR was merged into the 4.2-dev branch. Discussion ---------- [Serializer] XmlEncoder doesn't ignore PI nodes while encoding | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | / | License | MIT | Doc PR | / It's sometimes important to get only the XML body without the processing instructions (like the `<?xml version="1.0" ?>` on the top of your XML doc). At the moment, it's possible to ignore them while decoding, but not while encoding. ```php $encoder = new XmlEncoder('response', null, $ignoredNodeTypes = [XML_PI_NODE]); echo $encoder->encode([], 'xml'); ``` ``` Expected: <response/> Actual: <?xml version="1.0"?> <response/> ``` So, a new `$encoderIgnoredNodeTypes` arg is added to the constructor which will be: ```php public function __construct(string $rootNodeName = 'response', int $loadOptions = null, array $decoderIgnoredNodeTypes = array(XML_PI_NODE, XML_COMMENT_NODE), array $encoderIgnoredNodeTypes = array()) ``` Commits ------- 2223fcc Allow to ignore PI while encoding
- Loading branch information
Showing
2 changed files
with
21 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters