From 2cffba94b30f22d02efab380078a84d9e3c5eb92 Mon Sep 17 00:00:00 2001 From: freek Date: Wed, 14 Oct 2020 10:38:31 +0200 Subject: [PATCH] wip --- psalm-baseline.xml | 51 +++++++++++++++++++ psalm.xml | 1 + ...ssingLivewireComponentSolutionProvider.php | 18 +++++-- src/Solutions/LivewireDiscoverSolution.php | 4 +- 4 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 psalm-baseline.xml diff --git a/psalm-baseline.xml b/psalm-baseline.xml new file mode 100644 index 00000000..0133da90 --- /dev/null +++ b/psalm-baseline.xml @@ -0,0 +1,51 @@ + + + + + $this->app + $this->app + $this->app + $this->app + $this->app + $this->app + $this->app + + + + + $this->app + + + + + $this->app + $this->app + $this->app + + + + + ComponentNotFoundException + + + + + app('validator') + + + + + LivewireComponentsFinder + + + + + $baseException + + + + + $baseException + + + diff --git a/psalm.xml b/psalm.xml index 56e9470d..6beafbdd 100644 --- a/psalm.xml +++ b/psalm.xml @@ -7,6 +7,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + errorBaseline="psalm-baseline.xml" > diff --git a/src/SolutionProviders/MissingLivewireComponentSolutionProvider.php b/src/SolutionProviders/MissingLivewireComponentSolutionProvider.php index 9975bee4..999d17af 100644 --- a/src/SolutionProviders/MissingLivewireComponentSolutionProvider.php +++ b/src/SolutionProviders/MissingLivewireComponentSolutionProvider.php @@ -13,12 +13,10 @@ class MissingLivewireComponentSolutionProvider implements HasSolutionsForThrowab { public function canSolve(Throwable $throwable): bool { - if (! class_exists(ComponentNotFoundException::class)) { - return false; - } - if (! class_exists(LivewireComponentsFinder::class)) { + if (! $this->livewireIsInstalled()) { return false; } + if (! $throwable instanceof ComponentNotFoundException) { return false; } @@ -30,4 +28,16 @@ public function getSolutions(Throwable $throwable): array { return [new LivewireDiscoverSolution('A livewire component was not found')]; } + + public function livewireIsInstalled(): bool + { + if (! class_exists(ComponentNotFoundException::class)) { + return false; + } + if (! class_exists(LivewireComponentsFinder::class)) { + return false; + } + + return true; + } } diff --git a/src/Solutions/LivewireDiscoverSolution.php b/src/Solutions/LivewireDiscoverSolution.php index b4ba545b..2d5cb919 100644 --- a/src/Solutions/LivewireDiscoverSolution.php +++ b/src/Solutions/LivewireDiscoverSolution.php @@ -21,7 +21,7 @@ public function getSolutionTitle(): string public function getSolutionDescription(): string { - return 'You might have forgotten to discover your livewire components. You can discover your livewire components using `php artisan livewire:discover`.'; + return 'You might have forgotten to discover your Livewire components. You can discover your Livewire components using `php artisan livewire:discover`.'; } public function getDocumentationLinks(): array @@ -38,7 +38,7 @@ public function getRunParameters(): array public function getSolutionActionDescription(): string { - return 'Pressing the button below will try to discover your components.'; + return 'Pressing the button below will try to discover your Livewire components.'; } public function getRunButtonText(): string