Skip to content

Commit

Permalink
Removing reflection based system for callable detection
Browse files Browse the repository at this point in the history
  • Loading branch information
moufmouf committed Apr 19, 2016
1 parent 58fc601 commit 5e83730
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"symfony/framework-bundle": "^2.7 | ^3.0",
"puli/cli": "^1.0",
"puli/symfony-bundle": "^1.0",
"thecodingmachine/service-provider-registry": "^1.0",
"php-di/invoker": "^1.3"
"thecodingmachine/service-provider-registry": "^1.0"
},
"require-dev": {
"php": ">=5.6",
Expand Down
12 changes: 2 additions & 10 deletions src/ServiceProviderCompilationPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,8 @@ private function getServiceDefinitionFromCallable($serviceName, $serviceProvider
$factoryDefinition = new Definition('Class'); // TODO: in PHP7, we can get the return type of the function!
$containerDefinition = new Reference('interop_service_provider_acclimated_container');

$callableReflection = CallableReflection::create($callable);

if ($callableReflection instanceof \ReflectionMethod && $callableReflection->isStatic() && $callableReflection->isPublic()) {
$factoryDefinition->setFactory([
$callableReflection->getDeclaringClass()->getName(),
$callableReflection->getName()
]);
$factoryDefinition->addArgument(new Reference('interop_service_provider_acclimated_container'));
} elseif ($callableReflection instanceof \ReflectionFunction && !$callable instanceof \Closure) {
$factoryDefinition->setFactory($callableReflection->getName());
if ((is_array($callable) && is_string($callable[0])) || is_string($callable)) {
$factoryDefinition->setFactory($callable);
$factoryDefinition->addArgument(new Reference('interop_service_provider_acclimated_container'));
} else {
$factoryDefinition->setFactory([ new Reference('service_provider_registry_'.$this->registryId), 'createService' ]);
Expand Down

0 comments on commit 5e83730

Please sign in to comment.