From 2a4bf1d9fbcc3aa94b0612dd38af83dca65fa44f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 23 Feb 2023 07:39:50 +0000 Subject: [PATCH] [1.x] Adds type checking (#649) * Adds type checking * Fixes tests * Update .gitattributes * Update static-analysis.yml --- .gitattributes | 1 + .github/workflows/static-analysis.yml | 42 +++++++++++++++++++++++++++ composer.json | 5 ++++ phpstan.neon.dist | 12 ++++++++ src/Swoole/Handlers/OnWorkerStart.php | 2 +- 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/static-analysis.yml create mode 100644 phpstan.neon.dist diff --git a/.gitattributes b/.gitattributes index f9347ec94..4a2ab9807 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13,5 +13,6 @@ .gitignore export-ignore .styleci.yml export-ignore CHANGELOG.md export-ignore +phpstan.neon.dist export-ignore phpunit.xml.dist export-ignore UPGRADE.md export-ignore diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 000000000..52ad657b8 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,42 @@ +name: static analysis + +on: + push: + branches: + - master + - '*.x' + pull_request: + +permissions: + contents: read + +jobs: + tests: + runs-on: ubuntu-22.04 + + strategy: + fail-fast: true + + name: Static Analysis + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + tools: composer:v2 + coverage: none + extensions: swoole + + - name: Install dependencies + uses: nick-fields/retry@v2 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress + + - name: Execute type checking + run: vendor/bin/phpstan diff --git a/composer.json b/composer.json index 3c1a83f88..28c6b7d60 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,14 @@ }, "require-dev": { "guzzlehttp/guzzle": "^7.2", + "inertiajs/inertia-laravel": "^0.6.9", + "laravel/scout": "^9.8", + "laravel/socialite": "^5.6", + "livewire/livewire": "^2.12", "mockery/mockery": "^1.4", "nunomaduro/collision": "^5.10|^6.0|^7.0", "orchestra/testbench": "^6.16|^7.0|^8.0", + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.3", "spiral/roadrunner": "^2.8.2" }, diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 000000000..f4bf4fbbb --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,12 @@ +parameters: + paths: + - bin + - config + - src + + level: 0 + + ignoreErrors: + - "#Unsafe usage of new static\\(\\)#" + - "#\\(void\\) is used.#" + - "#Function Swoole\\\\Coroutine\\\\run not found.#" diff --git a/src/Swoole/Handlers/OnWorkerStart.php b/src/Swoole/Handlers/OnWorkerStart.php index 4d27b0356..e4f9e6956 100644 --- a/src/Swoole/Handlers/OnWorkerStart.php +++ b/src/Swoole/Handlers/OnWorkerStart.php @@ -55,7 +55,7 @@ public function __invoke($server, int $workerId) * Boot the Octane worker and application. * * @param \Swoole\Http\Server $server - * @return \Laravel\Octane\Worker + * @return \Laravel\Octane\Worker|null */ protected function bootWorker($server) {