Skip to content

Commit 9f51cf4

Browse files
committed
Deprecate the XmlEncoder::TYPE_CASE_ATTRIBUTES constant
1 parent 3a1d361 commit 9f51cf4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
7+
* [DEPRECATION] The `XmlEncoder::TYPE_CASE_ATTRIBUTES` constant is deprecated.
8+
Use `XmlEncoder::TYPE_CAST_ATTRIBUTES` instead
9+
410
4.3.0
511
-----
612

src/Symfony/Component/Serializer/Encoder/XmlEncoder.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
5151
const REMOVE_EMPTY_TAGS = 'remove_empty_tags';
5252
const ROOT_NODE_NAME = 'xml_root_node_name';
5353
const STANDALONE = 'xml_standalone';
54+
55+
/** @deprecated The constant TYPE_CASE_ATTRIBUTES is deprecated since version 4.4 and will be removed in version 5. Use TYPE_CAST_ATTRIBUTES instead. */
5456
const TYPE_CASE_ATTRIBUTES = 'xml_type_cast_attributes';
57+
const TYPE_CAST_ATTRIBUTES = 'xml_type_cast_attributes';
5558
const VERSION = 'xml_version';
5659

5760
private $defaultContext = [
@@ -61,7 +64,7 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
6164
self::LOAD_OPTIONS => LIBXML_NONET | LIBXML_NOBLANKS,
6265
self::REMOVE_EMPTY_TAGS => false,
6366
self::ROOT_NODE_NAME => 'response',
64-
self::TYPE_CASE_ATTRIBUTES => true,
67+
self::TYPE_CAST_ATTRIBUTES => true,
6568
];
6669

6770
/**
@@ -335,7 +338,7 @@ private function parseXmlAttributes(\DOMNode $node, array $context = []): array
335338
}
336339

337340
$data = [];
338-
$typeCastAttributes = (bool) ($context[self::TYPE_CASE_ATTRIBUTES] ?? $this->defaultContext[self::TYPE_CASE_ATTRIBUTES]);
341+
$typeCastAttributes = (bool) ($context[self::TYPE_CAST_ATTRIBUTES] ?? $this->defaultContext[self::TYPE_CAST_ATTRIBUTES]);
339342

340343
foreach ($node->attributes as $attr) {
341344
if (!is_numeric($attr->nodeValue) || !$typeCastAttributes || (isset($attr->nodeValue[1]) && '0' === $attr->nodeValue[0])) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy