Skip to content

Commit cb2826a

Browse files
author
Toufik
committed
Making container wrapper return understandable exceptions
Adding some more checks to has() to avoid having container entries not resolvable crash the whole GraphQLite
1 parent 2c5f3f3 commit cb2826a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/SanePsr11ContainerAdapter.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
use function class_exists;
8+
use Illuminate\Container\EntryNotFoundException;
89
use Illuminate\Contracts\Container\Container;
910
use Psr\Container\ContainerExceptionInterface;
1011
use Psr\Container\ContainerInterface;
@@ -54,9 +55,14 @@ public function get($id)
5455
*/
5556
public function has($id)
5657
{
57-
if (class_exists($id)) {
58+
if (class_exists($id) && !$this->container->has($id)) {
59+
try {
60+
$this->container->get($id);
61+
} catch (EntryNotFoundException $e) {
62+
return false;
63+
}
5864
return true;
5965
}
6066
return $this->container->has($id);
6167
}
62-
}
68+
}

0 commit comments

Comments
 (0)