From e60d2b77522efb04f96a282404ca46039713131a Mon Sep 17 00:00:00 2001 From: Max Ageev Date: Thu, 9 Jun 2022 17:21:57 +0300 Subject: [PATCH 1/2] Catch even Throwable when trying to create class If class require connection to database for creation for example getting state from there and saving to property. This break psalm anaylis currently. This case happen when CI environment does not have connection to database. --- src/Util/ContainerResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/ContainerResolver.php b/src/Util/ContainerResolver.php index 16c8577..299b20a 100644 --- a/src/Util/ContainerResolver.php +++ b/src/Util/ContainerResolver.php @@ -42,7 +42,7 @@ final class ContainerResolver // dynamic analysis to resolve the actual type from the container try { $concrete = ApplicationProvider::getApp()->make($abstract); - } catch (BindingResolutionException | ReflectionException $e) { + } catch (\Throwable $e) { return null; } From c35a229860e3a90c3f09097785f4c5ea6e03d376 Mon Sep 17 00:00:00 2001 From: Max Ageev Date: Thu, 9 Jun 2022 17:22:58 +0300 Subject: [PATCH 2/2] Remove use --- src/Util/ContainerResolver.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Util/ContainerResolver.php b/src/Util/ContainerResolver.php index 299b20a..9225ac5 100644 --- a/src/Util/ContainerResolver.php +++ b/src/Util/ContainerResolver.php @@ -4,14 +4,12 @@ declare(strict_types=1); namespace Psalm\LaravelPlugin\Util; -use Illuminate\Contracts\Container\BindingResolutionException; use PhpParser\Node\Arg; use Psalm\LaravelPlugin\Providers\ApplicationProvider; use Psalm\NodeTypeProvider; use Psalm\Type\Atomic\TLiteralString; use Psalm\Type\Atomic\TNamedObject; use Psalm\Type\Union; -use ReflectionException; use function array_key_exists; use function class_exists;