From 85a1384de6cd5888742cea7741564d846fde65af Mon Sep 17 00:00:00 2001 From: Alessio Vertemati Date: Fri, 21 Feb 2025 12:37:59 +0100 Subject: [PATCH] Move to PHPStan for static analysis --- .github/workflows/phpstan.yml | 28 ++++++++++++++++ .github/workflows/psalm.yml | 33 ------------------- composer.json | 14 +++++--- phpstan.neon.dist | 11 +++++++ psalm.xml.dist | 16 --------- ...ravelLanguageRecognizerServiceProvider.php | 2 +- 6 files changed, 50 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/phpstan.yml delete mode 100644 .github/workflows/psalm.yml create mode 100644 phpstan.neon.dist delete mode 100644 psalm.xml.dist diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..ecc8844 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,28 @@ +name: PHPStan + +on: + push: + paths: + - '**.php' + - 'phpstan.neon.dist' + - '.github/workflows/phpstan.yml' + +jobs: + phpstan: + name: phpstan + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + coverage: none + + - name: Install composer dependencies + uses: ramsey/composer-install@v3 + + - name: Run PHPStan + run: ./vendor/bin/phpstan --error-format=github \ No newline at end of file diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml deleted file mode 100644 index 448cb34..0000000 --- a/.github/workflows/psalm.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Psalm - -on: - push: - paths: - - '**.php' - - 'psalm.xml.dist' - -jobs: - psalm: - name: psalm - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick - coverage: none - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: vendor - key: composer-${{ hashFiles('composer.lock') }} - - - name: Run composer install - run: composer install -n --prefer-dist - - - name: Run psalm - run: ./vendor/bin/psalm --output-format=github diff --git a/composer.json b/composer.json index 5b4e665..d6e2d55 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,9 @@ "nunomaduro/collision": "^7.0|^8.0", "orchestra/testbench": "^8.0|^9.0", "phpunit/phpunit": "^10.5|^11.0", - "vimeo/psalm": "^5.0", + "larastan/larastan": "^2.9||^3.0", + "phpstan/phpstan-deprecation-rules": "^1.1||^2.0", + "phpstan/phpstan-phpunit": "^1.3||^2.0", "guzzlehttp/guzzle": "^7.0.1" }, "autoload": { @@ -41,12 +43,16 @@ } }, "scripts": { - "psalm": "vendor/bin/psalm", + "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/phpunit --no-coverage", "test-coverage": "vendor/bin/phpunit --coverage-html coverage" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true, + "phpstan/extension-installer": true + } }, "extra": { "laravel": { @@ -55,6 +61,6 @@ ] } }, - "minimum-stability": "dev", + "minimum-stability": "stable", "prefer-stable": true } diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..93198f5 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,11 @@ +includes: + - vendor/larastan/larastan/extension.neon + +parameters: + level: 5 + paths: + - src + - tests + tmpDir: build/phpstan + checkOctaneCompatibility: true + checkModelProperties: true \ No newline at end of file diff --git a/psalm.xml.dist b/psalm.xml.dist deleted file mode 100644 index c6df33e..0000000 --- a/psalm.xml.dist +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - diff --git a/src/LaravelLanguageRecognizerServiceProvider.php b/src/LaravelLanguageRecognizerServiceProvider.php index ad47dc9..cb3339d 100644 --- a/src/LaravelLanguageRecognizerServiceProvider.php +++ b/src/LaravelLanguageRecognizerServiceProvider.php @@ -27,7 +27,7 @@ public function register() 'language-recognizer' ); - $this->app->singleton(LaravelLanguageRecognizer::class, function ($app) { + $this->app->bind(LaravelLanguageRecognizer::class, function ($app) { return new LaravelLanguageRecognizer($app); }); }