Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2f69af

Browse filesBrowse files
KevinVanSonsbeeknicolas-grekas
authored andcommitted
[DependencyInjection] Fix linting factories implemented via __callStatic
1 parent ebd2270 commit e2f69af
Copy full SHA for e2f69af

File tree

2 files changed

+22
-0
lines changed
Filter options

2 files changed

+22
-0
lines changed

‎src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ protected function getReflectionMethod(Definition $definition, string $method)
202202
return new \ReflectionMethod(static function (...$arguments) {}, '__invoke');
203203
}
204204

205+
if ($r->hasMethod('__callStatic') && ($r = $r->getMethod('__callStatic')) && $r->isPublic()) {
206+
return new \ReflectionMethod(static function (...$arguments) {}, '__invoke');
207+
}
208+
205209
throw new RuntimeException(sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
206210
}
207211

‎src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/CheckTypeDeclarationsPassTest.php
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,17 @@ public function testCallableClass()
10151015
$this->addToAssertionCount(1);
10161016
}
10171017

1018+
public function testStaticCallableClass()
1019+
{
1020+
$container = new ContainerBuilder();
1021+
$container->register('foo', StaticCallableClass::class)
1022+
->setFactory([StaticCallableClass::class, 'staticMethodCall']);
1023+
1024+
(new CheckTypeDeclarationsPass())->process($container);
1025+
1026+
$this->addToAssertionCount(1);
1027+
}
1028+
10181029
public function testIgnoreDefinitionFactoryArgument()
10191030
{
10201031
$container = new ContainerBuilder();
@@ -1050,3 +1061,10 @@ public function __call($name, $arguments)
10501061
{
10511062
}
10521063
}
1064+
1065+
class StaticCallableClass
1066+
{
1067+
public static function __callStatic($name, $arguments)
1068+
{
1069+
}
1070+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.