Skip to content

Commit 7b9f9d1

Browse files
committed
Merge branch '4.4' into 5.3
* 4.4: [Mime] Fix encoding filenames in multipart/form-data [Validator] Improve French translation [Translations] Add missing translations for Galician (gl) [DependencyInjection] fix linting callable classes restore the overriden locale on tearDown - avoid interfering with any configured value [DependencyInjection] Cast tag value to string
2 parents 6414788 + 25771ea commit 7b9f9d1

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
@@ -198,6 +198,10 @@ protected function getReflectionMethod(Definition $definition, string $method)
198198
}
199199

200200
if (!$r->hasMethod($method)) {
201+
if ($r->hasMethod('__call') && ($r = $r->getMethod('__call')) && $r->isPublic()) {
202+
return new \ReflectionMethod(static function (...$arguments) {}, '__invoke');
203+
}
204+
201205
throw new RuntimeException(sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
202206
}
203207

Dumper/XmlDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private function addService(Definition $definition, ?string $id, \DOMElement $pa
143143
$tag->appendChild($this->document->createTextNode($name));
144144
}
145145
foreach ($attributes as $key => $value) {
146-
$tag->setAttribute($key, $value);
146+
$tag->setAttribute($key, $value ?? '');
147147
}
148148
$service->appendChild($tag);
149149
}

Tests/Compiler/CheckTypeDeclarationsPassTest.php

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

986986
(new CheckTypeDeclarationsPass(true))->process($container);
987987
}
988+
989+
public function testCallableClass()
990+
{
991+
$container = new ContainerBuilder();
992+
$definition = $container->register('foo', CallableClass::class);
993+
$definition->addMethodCall('callMethod', [123]);
994+
995+
(new CheckTypeDeclarationsPass())->process($container);
996+
997+
$this->addToAssertionCount(1);
998+
}
999+
}
1000+
1001+
class CallableClass
1002+
{
1003+
public function __call($name, $arguments)
1004+
{
1005+
}
9881006
}

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)