File tree 2 files changed +11
-0
lines changed
src/Symfony/Component/Serializer
2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -160,4 +160,12 @@ public function withCdataWrappingPattern(?string $cdataWrappingPattern): static
160
160
{
161
161
return $ this ->with (XmlEncoder::CDATA_WRAPPING_PATTERN , $ cdataWrappingPattern );
162
162
}
163
+
164
+ /**
165
+ * Configures whether to ignore empty attributes.
166
+ */
167
+ public function withIgnoreEmptyAttributes (?bool $ ignoreEmptyAttributes ): static
168
+ {
169
+ return $ this ->with (XmlEncoder::IGNORE_EMPTY_ATTRIBUTES , $ ignoreEmptyAttributes );
170
+ }
163
171
}
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ public function testWithers(array $values)
47
47
->withVersion ($ values [XmlEncoder::VERSION ])
48
48
->withCdataWrapping ($ values [XmlEncoder::CDATA_WRAPPING ])
49
49
->withCdataWrappingPattern ($ values [XmlEncoder::CDATA_WRAPPING_PATTERN ])
50
+ ->withIgnoreEmptyAttributes ($ values [XmlEncoder::IGNORE_EMPTY_ATTRIBUTES ])
50
51
->toArray ();
51
52
52
53
$ this ->assertSame ($ values , $ context );
@@ -69,6 +70,7 @@ public static function withersDataProvider(): iterable
69
70
XmlEncoder::VERSION => '1.0 ' ,
70
71
XmlEncoder::CDATA_WRAPPING => false ,
71
72
XmlEncoder::CDATA_WRAPPING_PATTERN => '/[<>&" \']/ ' ,
73
+ XmlEncoder::IGNORE_EMPTY_ATTRIBUTES => true ,
72
74
]];
73
75
74
76
yield 'With null values ' => [[
@@ -86,6 +88,7 @@ public static function withersDataProvider(): iterable
86
88
XmlEncoder::VERSION => null ,
87
89
XmlEncoder::CDATA_WRAPPING => null ,
88
90
XmlEncoder::CDATA_WRAPPING_PATTERN => null ,
91
+ XmlEncoder::IGNORE_EMPTY_ATTRIBUTES => null ,
89
92
]];
90
93
}
91
94
}
You can’t perform that action at this time.
0 commit comments