File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
src/Symfony/Component/Serializer Expand file tree Collapse file tree 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
160160 {
161161 return $ this ->with (XmlEncoder::CDATA_WRAPPING_PATTERN , $ cdataWrappingPattern );
162162 }
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+ }
163171}
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ public function testWithers(array $values)
4747 ->withVersion ($ values [XmlEncoder::VERSION ])
4848 ->withCdataWrapping ($ values [XmlEncoder::CDATA_WRAPPING ])
4949 ->withCdataWrappingPattern ($ values [XmlEncoder::CDATA_WRAPPING_PATTERN ])
50+ ->withIgnoreEmptyAttributes ($ values [XmlEncoder::IGNORE_EMPTY_ATTRIBUTES ])
5051 ->toArray ();
5152
5253 $ this ->assertSame ($ values , $ context );
@@ -69,6 +70,7 @@ public static function withersDataProvider(): iterable
6970 XmlEncoder::VERSION => '1.0 ' ,
7071 XmlEncoder::CDATA_WRAPPING => false ,
7172 XmlEncoder::CDATA_WRAPPING_PATTERN => '/[<>&" \']/ ' ,
73+ XmlEncoder::IGNORE_EMPTY_ATTRIBUTES => true ,
7274 ]];
7375
7476 yield 'With null values ' => [[
@@ -86,6 +88,7 @@ public static function withersDataProvider(): iterable
8688 XmlEncoder::VERSION => null ,
8789 XmlEncoder::CDATA_WRAPPING => null ,
8890 XmlEncoder::CDATA_WRAPPING_PATTERN => null ,
91+ XmlEncoder::IGNORE_EMPTY_ATTRIBUTES => null ,
8992 ]];
9093 }
9194}
You can’t perform that action at this time.
0 commit comments