Skip to content

Commit 20d3c92

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Don't rely on session service in tests [Mime] Fix encoding filenames in multipart/form-data Properly warn about deprecation of IS_AUTHENTICATED_ANONYMOUSLY [Lock] Create tables in transaction only if supported by driver [Validator] Improve French translation [HttpFoundation] Take php session.cookie settings into account [Translations] Add missing translations for Galician (gl) [ErrorHandler] fix on patching return types on Windows [DependencyInjection] fix linting callable classes alias `cache.app.taggable` to `cache.app` if using `cache.adapter.redis_tag_aware` restore the overriden locale on tearDown - avoid interfering with any configured value [Serializer] Improve UidNormalizer denormalize error message [DependencyInjection] Cast tag value to string
2 parents 4a83dbc + a7e4cff commit 20d3c92

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

Compiler/AbstractRecursivePass.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ protected function getReflectionMethod(Definition $definition, string $method):
192192
}
193193

194194
if (!$r->hasMethod($method)) {
195+
if ($r->hasMethod('__call') && ($r = $r->getMethod('__call')) && $r->isPublic()) {
196+
return new \ReflectionMethod(static function (...$arguments) {}, '__invoke');
197+
}
198+
195199
throw new RuntimeException(sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
196200
}
197201

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->appendChild($this->document->createTextNode($name));
139139
}
140140
foreach ($attributes as $key => $value) {
141-
$tag->setAttribute($key, $value);
141+
$tag->setAttribute($key, $value ?? '');
142142
}
143143
$service->appendChild($tag);
144144
}

Tests/Compiler/CheckTypeDeclarationsPassTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,4 +961,22 @@ public function testIntersectionTypeFailsWithReference()
961961

962962
(new CheckTypeDeclarationsPass(true))->process($container);
963963
}
964+
965+
public function testCallableClass()
966+
{
967+
$container = new ContainerBuilder();
968+
$definition = $container->register('foo', CallableClass::class);
969+
$definition->addMethodCall('callMethod', [123]);
970+
971+
(new CheckTypeDeclarationsPass())->process($container);
972+
973+
$this->addToAssertionCount(1);
974+
}
975+
}
976+
977+
class CallableClass
978+
{
979+
public function __call($name, $arguments)
980+
{
981+
}
964982
}

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
->addTag('foo', ['name' => 'bar', 'baz' => 'baz'])
2122
->setFactory(['Bar\\FooClass', 'getInstance'])
2223
->setArguments(['foo', new Reference('foo.baz'), ['%foo%' => 'foo is %foo%', 'foobar' => '%foo%'], true, new Reference('service_container')])

Tests/Fixtures/xml/services9.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<tag name="foo" foo="foo"/>
1212
<tag name="foo" bar="bar" baz="baz"/>
1313
<tag name="bar" baz="baz">foo</tag>
14+
<tag name="nullable" bar="bar" baz=""/>
1415
<argument>foo</argument>
1516
<argument type="service" id="foo.baz"/>
1617
<argument type="collection">

Tests/Fixtures/yaml/services9.yml

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

0 commit comments

Comments
 (0)