Skip to content

Commit

Permalink
Add helper method isStaticallyCallable
Browse files Browse the repository at this point in the history
  • Loading branch information
bnf committed Sep 12, 2018
1 parent d8cf411 commit 48e44c0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ServiceProviderCompilationPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private function addServiceDefinitionFromCallable($serviceName, $serviceProvider
$factoryDefinition->setDecoratedService($previousServiceName, $innerName);
}

if ((is_array($callable) && is_string($callable[0])) || is_string($callable)) {
if ($this->isStaticallyCallable($callable)) {
$factoryDefinition->setFactory($callable);
} else {
$factoryDefinition->setFactory([ new Reference('service_provider_registry_'.$this->registryId), $method ]);
Expand All @@ -135,6 +135,11 @@ private function addServiceDefinitionFromCallable($serviceName, $serviceProvider
$container->setDefinition($finalServiceName, $factoryDefinition);
}

private function isStaticallyCallable(callable $callable): bool
{
return (is_array($callable) && is_string($callable[0])) || is_string($callable);
}

private function getReturnType(callable $callable, string $serviceName): string
{
return $this->getReflection($callable)->getReturnType() ?: $serviceName;
Expand Down

0 comments on commit 48e44c0

Please sign in to comment.