Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 11, 2021
1 parent 0f79023 commit a712f72
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
21 changes: 10 additions & 11 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Closure;
use Exception;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Contracts\Container\CircularDependencyFoundException;
use Illuminate\Contracts\Container\CircularDependencyException;
use Illuminate\Contracts\Container\Container as ContainerContract;
use LogicException;
use ReflectionClass;
Expand Down Expand Up @@ -660,7 +660,7 @@ public function get($id)
try {
return $this->resolve($id);
} catch (Exception $e) {
if ($this->has($id) || $e instanceof CircularDependencyFoundException) {
if ($this->has($id) || $e instanceof CircularDependencyException) {
throw $e;
}

Expand All @@ -671,13 +671,13 @@ public function get($id)
/**
* Resolve the given type from the container.
*
* @param string|callable $abstract
* @param array $parameters
* @param bool $raiseEvents
* @param string|callable $abstract
* @param array $parameters
* @param bool $raiseEvents
* @return mixed
*
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \Illuminate\Contracts\Container\CircularDependencyFoundException
* @throws \Illuminate\Contracts\Container\CircularDependencyException
*/
protected function resolve($abstract, $parameters = [], $raiseEvents = true)
{
Expand Down Expand Up @@ -814,11 +814,11 @@ protected function isBuildable($concrete, $abstract)
/**
* Instantiate a concrete instance of the given type.
*
* @param \Closure|string $concrete
* @param \Closure|string $concrete
* @return mixed
*
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \Illuminate\Contracts\Container\CircularDependencyFoundException
* @throws \Illuminate\Contracts\Container\CircularDependencyException
*/
public function build($concrete)
{
Expand All @@ -842,9 +842,8 @@ public function build($concrete)
return $this->notInstantiable($concrete);
}

// Check for circular dependencies
if(in_array($concrete, $this->buildStack)) {
throw new CircularDependencyFoundException("Circular dependency while initiating [{$concrete}]");
if (in_array($concrete, $this->buildStack)) {
throw new CircularDependencyException("Circular dependency detected while resolving [{$concrete}].");
}

$this->buildStack[] = $concrete;
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions tests/Container/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Container\Container;
use Illuminate\Container\EntryNotFoundException;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Contracts\Container\CircularDependencyFoundException;
use Illuminate\Contracts\Container\CircularDependencyException;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerExceptionInterface;
use stdClass;
Expand Down Expand Up @@ -565,7 +565,7 @@ public function testContainerCanResolveClasses()
}

public function testContainerCanCatchCircularDependency() {
$this->expectException(CircularDependencyFoundException::class);
$this->expectException(CircularDependencyException::class);

$container = new Container;
$container->get(CircularAStub::class);
Expand Down

0 comments on commit a712f72

Please sign in to comment.