Skip to content

Commit d725ebd

Browse files
authored
Merge pull request #1619 from NikoGrano/patch-1
Fix case-insensitive boolean deserialization
2 parents fff5118 + 3ebc24c commit d725ebd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/XmlDeserializationVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function visitBoolean($data, array $type): bool
142142
{
143143
$this->assertValueCanBeCastToString($data);
144144

145-
$data = (string) $data;
145+
$data = strtolower((string) $data);
146146

147147
if ('true' === $data || '1' === $data) {
148148
return true;

tests/Serializer/XmlSerializationTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,16 @@ public function testXMLBooleans($xmlBoolean, $boolean)
7979

8080
public static function getXMLBooleans()
8181
{
82-
return [['true', true], ['false', false], ['1', true], ['0', false]];
82+
return [
83+
['true', true],
84+
['false', false],
85+
['1', true],
86+
['0', false],
87+
['True', true],
88+
['False', false],
89+
['TRUE', true],
90+
['FALSE', false],
91+
];
8392
}
8493

8594
public function testAccessorSetterDeserialization()

0 commit comments

Comments
 (0)