From b56d5e8bcc945c2f48e07cb5a7e93796f2120654 Mon Sep 17 00:00:00 2001 From: abenettt Date: Mon, 26 Jul 2021 12:54:21 +0200 Subject: [PATCH] Add phpstan/larastan --- .github/workflows/phpstan.yml | 26 +++++++++++++++++++++++++ .github/workflows/psalm.yml | 33 -------------------------------- .gitignore | 2 +- composer.json | 9 ++++++--- phpstan-baseline.neon | 0 phpstan.neon.dist | 15 +++++++++++++++ psalm.xml.dist | 16 ---------------- src/Commands/SkeletonCommand.php | 4 +++- tests/ExampleTest.php | 2 +- 9 files changed, 52 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/phpstan.yml delete mode 100644 .github/workflows/psalm.yml create mode 100644 phpstan-baseline.neon 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 00000000..19d6402d --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,26 @@ +name: PHPStan + +on: + push: + paths: + - '**.php' + - 'phpstan.neon.dist' + +jobs: + phpstan: + name: phpstan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + coverage: none + + - name: Install composer dependencies + uses: ramsey/composer-install@v1 + + - name: Run PHPStan + run: ./vendor/bin/phpstan --error-format=github diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml deleted file mode 100644 index e48b24f5..00000000 --- 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@v2 - - - 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@v2 - 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/.gitignore b/.gitignore index 0a63bc1a..9a436860 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ composer.lock coverage docs phpunit.xml -psalm.xml +phpstan.neon testbench.yaml vendor node_modules diff --git a/composer.json b/composer.json index 3e76e56e..8cd78374 100644 --- a/composer.json +++ b/composer.json @@ -23,10 +23,13 @@ "require-dev": { "brianium/paratest": "^6.2", "nunomaduro/collision": "^5.3", + "nunomaduro/larastan": "^0.7.10", "orchestra/testbench": "^6.15", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^0.12.6", + "phpstan/phpstan-phpunit": "^0.12.21", "phpunit/phpunit": "^9.3", - "spatie/laravel-ray": "^1.23", - "vimeo/psalm": "^4.8" + "spatie/laravel-ray": "^1.23" }, "autoload": { "psr-4": { @@ -40,7 +43,7 @@ } }, "scripts": { - "psalm": "vendor/bin/psalm", + "phpstan": "vendor/bin/phpstan analyse", "test": "./vendor/bin/testbench package:test --parallel --no-coverage", "test-coverage": "vendor/bin/phpunit --coverage-html coverage" }, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..e69de29b diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..58e81ef0 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,15 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 4 + paths: + - src + - config + - database + - tests + tmpDir: build/phpstan + checkOctaneCompatibility: true + checkModelProperties: true + checkMissingIterableValueType: false + diff --git a/psalm.xml.dist b/psalm.xml.dist deleted file mode 100644 index c6df33e7..00000000 --- a/psalm.xml.dist +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - diff --git a/src/Commands/SkeletonCommand.php b/src/Commands/SkeletonCommand.php index 4ce4c844..3e5f6280 100644 --- a/src/Commands/SkeletonCommand.php +++ b/src/Commands/SkeletonCommand.php @@ -10,8 +10,10 @@ class SkeletonCommand extends Command public $description = 'My command'; - public function handle() + public function handle(): int { $this->comment('All done'); + + return self::SUCCESS; } } diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php index a947396b..7f508f47 100644 --- a/tests/ExampleTest.php +++ b/tests/ExampleTest.php @@ -5,7 +5,7 @@ class ExampleTest extends TestCase { /** @test */ - public function true_is_true() + public function true_is_true(): void { $this->assertTrue(true); }