Skip to content

Commit 00974c5

Browse files
committed
Fix wrong behavior
1 parent 4bd02c7 commit 00974c5

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

src/Factory/CallableFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __invoke(ContainerInterface $container): mixed
5858
{
5959
$arguments = $this->getArguments($container, new \ReflectionFunction($this->callable));
6060

61-
return $this->callable->call($container, ...$arguments);
61+
return call_user_func_array($this->callable, $arguments);
6262
}
6363

6464
/**

src/ServiceProviderContainer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ private function applyServiceExtensions(string $id, mixed $service): void
127127
$extensions[$id]($this->wrapperContainer, $service);
128128
}
129129

130-
if ($id !== $class && \array_key_exists($class, $extensions) && \is_callable($extensions[$class])) {
130+
if ($id !== $class
131+
&& !isset($this->cache[$class])
132+
&& \array_key_exists($class, $extensions)
133+
&& \is_callable($extensions[$class])
134+
) {
131135
$extensions[$class]($this->wrapperContainer, $service);
132136
}
133137
}

tests/Factory/CallableFactoryTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ public function testInvokeWillReturnProvidedCallableReturns(): void
4646
self::assertTrue($result->resolved);
4747
}
4848

49-
public function testInvokeWillBindToContainer(): void
50-
{
51-
$container = $this->prophesize(ContainerInterface::class);
52-
$expected = $container->reveal();
53-
54-
$factory = new CallableFactory(fn () => $this);
55-
56-
$actual = $factory($expected);
57-
58-
self::assertSame($expected, $actual);
59-
}
60-
6149
public function testClosureReceivesContainerDependenciesAsArgument(): void
6250
{
6351
$container = $this->prophesize(ContainerInterface::class);

0 commit comments

Comments
 (0)