Skip to content

Commit 84ea16f

Browse files
committed
Fix possible circular dependecy
1 parent 2bf7e22 commit 84ea16f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/Factory/MethodFactory.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,14 @@ public function __construct(
6767
*/
6868
public function __invoke(ContainerInterface $container): mixed
6969
{
70-
$class = $container->has($this->class) ? $container->get($this->class) : $this->class;
71-
7270
$arguments = array_map(
7371
static fn ($argument) => \is_string($argument) && $container->has($argument)
7472
? $container->get($argument)
7573
: $argument,
7674
$this->arguments
7775
);
7876

79-
$reflectionMethod = new \ReflectionMethod($class, $this->method);
77+
$reflectionMethod = new \ReflectionMethod($this->class, $this->method);
8078

8179
if (!$reflectionMethod->isPublic()) {
8280
throw RuntimeException::forNonPublicMethod($this->class, $this->method);
@@ -86,6 +84,6 @@ public function __invoke(ContainerInterface $container): mixed
8684
return $reflectionMethod->invokeArgs(null, $arguments);
8785
}
8886

89-
return $reflectionMethod->invokeArgs($class, $arguments);
87+
return $reflectionMethod->invokeArgs(new ($this->class)(), $arguments);
9088
}
9189
}

0 commit comments

Comments
 (0)