Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 26e56fb

Browse files
committed
[DependencyInjection] Cast tag value to string
DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated This happens when a tag value is `null` on PHP 8.1.
1 parent 366f40a commit 26e56fb

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private function addService(Definition $definition, ?string $id, \DOMElement $pa
138138
$tag = $this->document->createElement('tag');
139139
$tag->setAttribute('name', $name);
140140
foreach ($attributes as $key => $value) {
141-
$tag->setAttribute($key, $value);
141+
$tag->setAttribute($key, (string) $value);
142142
}
143143
$service->appendChild($tag);
144144
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
->register('foo', FooClass::class)
1818
->addTag('foo', ['foo' => 'foo'])
1919
->addTag('foo', ['bar' => 'bar', 'baz' => 'baz'])
20+
->addTag('nullable', ['bar' => 'bar', 'baz' => null])
2021
->setFactory(['Bar\\FooClass', 'getInstance'])
2122
->setArguments(['foo', new Reference('foo.baz'), ['%foo%' => 'foo is %foo%', 'foobar' => '%foo%'], true, new Reference('service_container')])
2223
->setProperties(['foo' => 'bar', 'moo' => new Reference('foo.baz'), 'qux' => ['%foo%' => 'foo is %foo%', 'foobar' => '%foo%']])

src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<service id="foo" class="Bar\FooClass" public="true">
1111
<tag name="foo" foo="foo"/>
1212
<tag name="foo" bar="bar" baz="baz"/>
13+
<tag name="nullable" bar="bar" baz=""/>
1314
<argument>foo</argument>
1415
<argument type="service" id="foo.baz"/>
1516
<argument type="collection">

src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
tags:
1414
- { name: foo, foo: foo }
1515
- { name: foo, bar: bar, baz: baz }
16+
- { name: nullable, bar: bar, baz: ~ }
1617
arguments: [foo, '@foo.baz', { '%foo%': 'foo is %foo%', foobar: '%foo%' }, true, '@service_container']
1718
properties: { foo: bar, moo: '@foo.baz', qux: { '%foo%': 'foo is %foo%', foobar: '%foo%' } }
1819
calls:

0 commit comments

Comments
 (0)