Skip to content

Commit

Permalink
Repaired container aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
jshannon63 committed Apr 17, 2018
1 parent 8154ebb commit 2de4312
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public function __construct($mode = null)
$this->mode = $mode;
static::$container = $this;
$this->bind(self::class, $this);
$this->alias(ContainerInterface::class, $this);
$this->alias(CobaltContainerInterface::class, $this);
$this->alias(ContainerInterface::class, self::class);
$this->alias(CobaltContainerInterface::class, self::class);
}

/**
Expand Down Expand Up @@ -187,6 +187,9 @@ public function make($id, ...$args)
*/
private function create($id)
{
/* @var null|array */
$dependencies = [];

// Check if the binding already exists. Forces a bind
// whenever create is called internally.
if (! isset($this->bindings[$id])) {
Expand Down Expand Up @@ -244,14 +247,14 @@ private function processDependencies(&$binding): void

// Get the class constructor and see what we have. If there is no constructor,
// then return an empty array of dependencies.
if (! $constructor = $binding['reflector']->getConstructor()) {
if (! $binding['reflector']->getConstructor()) {
$binding['dependencies'] = [];

return;
}

// Otherwise get the constructor parameters and resolve them.
$binding['dependencies'] = $this->resolveParameters($constructor->getParameters());
$binding['dependencies'] = $this->resolveParameters($binding['reflector']->getConstructor()->getParameters());
}

/**
Expand Down

0 comments on commit 2de4312

Please sign in to comment.