Skip to content

Commit f9a5cc3

Browse files
committed
fix(docblock): throw NotFoundExceptionInterface instead of ContainerException
1 parent 207f0da commit f9a5cc3

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/Container.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function set(string $id, $concrete): void
6464
/**
6565
* @param class-string $id
6666
* @throws ContainerExceptionInterface
67+
* @throws NotFoundExceptionInterface
6768
*/
6869
private function resolve(string $id): object
6970
{
@@ -74,7 +75,7 @@ private function resolve(string $id): object
7475
throw new ContainerException("Class \"$id\" is not instantiable");
7576
}
7677
} catch (ReflectionException $reflectionException) {
77-
throw new ContainerException("Class \"$id\" does not exist");
78+
throw new NotFoundException("Class \"$id\" does not exist");
7879
}
7980

8081
$constructor = $reflectionClass->getConstructor();

tests/ContainerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use flight\Container;
66
use PHPUnit\Framework\TestCase;
77
use Psr\Container\ContainerExceptionInterface;
8+
use Psr\Container\NotFoundExceptionInterface;
89

910
/** @covers flight\Container */
1011
final class ContainerTest extends TestCase
@@ -30,7 +31,8 @@ public function test_it_throws_an_exception_when_the_class_does_not_exist(): voi
3031
{
3132
$container = new Container;
3233

33-
$this->expectException(ContainerExceptionInterface::class);
34+
self::expectException(NotFoundExceptionInterface::class);
35+
self::expectExceptionMessage('Class "NonExistentClass" does not exist');
3436

3537
$container->get('NonExistentClass'); // @phpstan-ignore-line
3638
}

0 commit comments

Comments
 (0)