Skip to content
Snippets Groups Projects

1.x

Merged Bartek Jaskulski requested to merge 1.x into review
7 files
+ 25
28
Compare changes
  • Side-by-side
  • Inline

Files

@@ -5,11 +5,11 @@ declare(strict_types=1);
@@ -5,11 +5,11 @@ declare(strict_types=1);
namespace WPDesk\Init\Binding\Binder;
namespace WPDesk\Init\Binding\Binder;
use Psr\Container\ContainerInterface;
use Psr\Container\ContainerInterface;
use WPDesk\Init\Binding\Binder;
use WPDesk\Init\Binding\ComposableBinder;
use WPDesk\Init\Binding\Definition;
use WPDesk\Init\Binding\Definition;
use WPDesk\Init\Binding\Definition\CallableDefinition;
use WPDesk\Init\Binding\Definition\CallableDefinition;
class CallableBinder implements Binder {
class CallableBinder implements ComposableBinder {
/** @var ContainerInterface */
/** @var ContainerInterface */
private $container;
private $container;
@@ -23,13 +23,11 @@ class CallableBinder implements Binder {
@@ -23,13 +23,11 @@ class CallableBinder implements Binder {
}
}
public function bind( Definition $def ): void {
public function bind( Definition $def ): void {
if ( $def instanceof CallableDefinition ) {
$ref = new \ReflectionFunction( $def->value() );
$ref = new \ReflectionFunction( $def->value() );
$parameters = [];
$parameters = [];
foreach ( $ref->getParameters() as $ref_param ) {
foreach ( $ref->getParameters() as $ref_param ) {
$parameters[] = $this->container->get( $ref_param->getType()->getName() );
$parameters[] = $this->container->get( $ref_param->getType()->getName() );
}
$ref->invokeArgs( $parameters );
}
}
 
$ref->invokeArgs( $parameters );
}
}
}
}
Loading