Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"monolog/monolog": "~1.12",
"mtdowling/cron-expression": "~1.0",
"nesbot/carbon": "~1.20",
"psr/container": "~1.0",
"ramsey/uuid": "~3.0",
"swiftmailer/swiftmailer": "~6.0",
"symfony/console": "~3.3",
Expand Down
20 changes: 20 additions & 0 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -1222,4 +1222,24 @@ public function __set($key, $value)
{
$this[$key] = $value;
}

/**
* {@inheritdoc}
*/
public function get($id)
{
if ($this->has($id)) {
return $this->resolve($id);
}

throw new EntryNotFoundException();
}

/**
* {@inheritdoc}
*/
public function has($id)
{
return $this->bound($id);
}
}
10 changes: 10 additions & 0 deletions src/Illuminate/Container/EntryNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Illuminate\Container;

use Exception;
use Psr\Container\NotFoundExceptionInterface;

class EntryNotFoundException extends Exception implements NotFoundExceptionInterface
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Illuminate\Contracts\Container;

use Exception;
use Psr\Container\ContainerExceptionInterface;

class BindingResolutionException extends Exception
class BindingResolutionException extends Exception implements ContainerExceptionInterface
{
//
}
3 changes: 2 additions & 1 deletion src/Illuminate/Contracts/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Illuminate\Contracts\Container;

use Closure;
use Psr\Container\ContainerInterface;

interface Container
interface Container extends ContainerInterface
{
/**
* Determine if the given abstract type has been bound.
Expand Down
16 changes: 16 additions & 0 deletions tests/Container/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,22 @@ public function testCanBuildWithoutParameterStackWithConstructors()
$container->bind('Illuminate\Tests\Container\IContainerContractStub', 'Illuminate\Tests\Container\ContainerImplementationStub');
$this->assertInstanceOf(ContainerDependentStub::class, $container->build(ContainerDependentStub::class));
}

public function testContainerKnowsEntry()
{
$container = new Container;
$container->bind('Illuminate\Tests\Container\IContainerContractStub', 'Illuminate\Tests\Container\ContainerImplementationStub');
$this->assertEquals(true, $container->has('Illuminate\Tests\Container\IContainerContractStub'));
}

/**
* @expectedException \Illuminate\Container\EntryNotFoundException
*/
public function testUnknownEntryThrowsException()
{
$container = new Container;
$container->get('Taylor');
}
}

class ContainerConcreteStub
Expand Down