From 97193a0de1377e3d77500a4ad70a415399f052d7 Mon Sep 17 00:00:00 2001 From: Ruben Van Assche Date: Thu, 2 May 2024 15:36:44 +0200 Subject: [PATCH] Fix PHPStan --- .github/workflows/phpstan.yml | 31 +++++++++++++++++++ phpstan-baseline.neon | 27 +++++++++++++++- .../LaravelLivewireRequestContextProvider.php | 2 +- 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 00000000..d8d3f125 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,31 @@ +name: PHPStan + +on: + push: + paths: + - '**.php' + - 'phpstan.neon.dist' + pull_request: + paths: + - '**.php' + - 'phpstan.neon.dist' + + +jobs: + phpstan: + name: phpstan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + coverage: none + + - name: Install composer dependencies + uses: ramsey/composer-install@v1 + + - name: Run PHPStan + run: ./vendor/bin/phpstan --error-format=github diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 278fddc5..d1dfb404 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,25 @@ parameters: ignoreErrors: + - + message: "#^Call to an undefined method Livewire\\\\LivewireManager\\:\\:getClass\\(\\)\\.$#" + count: 1 + path: src/ContextProviders/LaravelLivewireRequestContextProvider.php + + - + message: "#^Cannot call method get\\(\\) on Symfony\\\\Component\\\\HttpFoundation\\\\Request\\|null\\.$#" + count: 1 + path: src/ContextProviders/LaravelLivewireRequestContextProvider.php + + - + message: "#^Cannot call method has\\(\\) on Symfony\\\\Component\\\\HttpFoundation\\\\Request\\|null\\.$#" + count: 1 + path: src/ContextProviders/LaravelLivewireRequestContextProvider.php + + - + message: "#^Method Spatie\\\\LaravelIgnition\\\\ContextProviders\\\\LaravelLivewireRequestContextProvider\\:\\:resolveUpdates\\(\\) has parameter \\$updates with no value type specified in iterable type array\\.$#" + count: 1 + path: src/ContextProviders/LaravelLivewireRequestContextProvider.php + - message: "#^Cannot call method toFlare\\(\\) on class\\-string\\|object\\.$#" count: 1 @@ -25,6 +45,11 @@ parameters: count: 1 path: src/Exceptions/InvalidConfig.php + - + message: "#^Class Livewire\\\\LivewireComponentsFinder not found\\.$#" + count: 1 + path: src/Solutions/LivewireDiscoverSolution.php + - message: "#^Parameter \\#1 \\$invalidController of method Spatie\\\\LaravelIgnition\\\\Solutions\\\\SolutionProviders\\\\InvalidRouteActionSolutionProvider\\:\\:findRelatedController\\(\\) expects string, string\\|null given\\.$#" count: 1 @@ -46,7 +71,7 @@ parameters: path: src/Solutions/SolutionProviders/UnknownValidationSolutionProvider.php - - message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\\\:\\:filter\\(\\) expects \\(callable\\(ReflectionMethod, int\\)\\: bool\\)\\|null, Closure\\(ReflectionMethod\\)\\: 0\\|1\\|false given\\.$#" + message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\\\:\\:filter\\(\\) expects \\(callable\\(ReflectionMethod, int\\)\\: bool\\)\\|null, Closure\\(ReflectionMethod\\)\\: \\(0\\|1\\|false\\) given\\.$#" count: 1 path: src/Solutions/SolutionProviders/UnknownValidationSolutionProvider.php diff --git a/src/ContextProviders/LaravelLivewireRequestContextProvider.php b/src/ContextProviders/LaravelLivewireRequestContextProvider.php index cffaef94..ecaa8cbf 100644 --- a/src/ContextProviders/LaravelLivewireRequestContextProvider.php +++ b/src/ContextProviders/LaravelLivewireRequestContextProvider.php @@ -38,7 +38,7 @@ public function toArray(): array return $properties; } - /** @return array */ + /** @return array */ protected function getLivewireInformation(): array { if ($this->request->has('components')) {