From a9a84e099ca6c565a77f55dea5d8c620ebf1f0e5 Mon Sep 17 00:00:00 2001 From: Alan Gabriel Bem Date: Wed, 20 Apr 2022 00:38:09 +0200 Subject: [PATCH] installed psalm & phpstan --- .github/workflows/ci.yaml | 46 +++++++++++++++++++++++++++++++++++++++ README.md | 2 -- build/.phpstan/.gitkeep | 0 build/.psalm/.gitkeep | 0 composer.json | 16 ++++++++------ phpstan.neon | 6 +++++ psalm.xml | 16 ++++++++++++++ rector.php | 10 ++++++++- 8 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 build/.phpstan/.gitkeep create mode 100644 build/.psalm/.gitkeep create mode 100644 phpstan.neon create mode 100644 psalm.xml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3e034c57..179b293f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -119,3 +119,49 @@ jobs: run: docker-compose exec -T php composer install --no-scripts --no-interaction --ansi - name: Run deptrac run: docker-compose exec -T php bin/deptrac --no-progress --no-interaction --cache-file=./build/.deptrac/.deptrac.cache --ansi + run-phpstan: + name: phpstan + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Docker pull + run: docker-compose pull php + - name: Docker caching + uses: satackey/action-docker-layer-caching@v0.0.11 + continue-on-error: true + - name: Composer caching + uses: actions/cache@v2 + with: + path: ./build/.composer + key: ${{ runner.os }}-composer-v1-${{ hashFiles('composer.json') }} + restore-keys: ${{ runner.os }}-composer-v1- + - name: Start PHP container + run: docker-compose up --detach --build --no-deps php + - name: Install dependencies + run: docker-compose exec -T php composer install --no-scripts --no-interaction --ansi + - name: Run phpstan + run: docker-compose exec -T php bin/phpstan analyse -c phpstan.neon + run-psalm: + name: psalm + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Docker pull + run: docker-compose pull php + - name: Docker caching + uses: satackey/action-docker-layer-caching@v0.0.11 + continue-on-error: true + - name: Composer caching + uses: actions/cache@v2 + with: + path: ./build/.composer + key: ${{ runner.os }}-composer-v1-${{ hashFiles('composer.json') }} + restore-keys: ${{ runner.os }}-composer-v1- + - name: Start PHP container + run: docker-compose up --detach --build --no-deps php + - name: Install dependencies + run: docker-compose exec -T php composer install --no-scripts --no-interaction --ansi + - name: Run psalm + run: docker-compose exec -T php bin/psalm diff --git a/README.md b/README.md index 293d6387..b155d22f 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ Running checks & tests locally `docker-compose exec -T php xphp -dxdebug.mode=coverage bin/phpunit --color=always --configuration=phpunit.xml.dist` -`docker-compose run -T php bin/phpunit` - `docker-compose exec -T php bin/rector --dry-run --ansi` `docker-compose exec -T php bin/deptrac --no-interaction --cache-file=./build/.deptrac/.deptrac.cache --ansi` diff --git a/build/.phpstan/.gitkeep b/build/.phpstan/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/build/.psalm/.gitkeep b/build/.psalm/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/composer.json b/composer.json index e9141891..beb5a325 100644 --- a/composer.json +++ b/composer.json @@ -27,21 +27,23 @@ }, "require": { "php": ">=8.0", - "ext-pdo": "*", "ext-igbinary": "*", - "ext-redis": "*", "ext-json": "*", + "ext-pdo": "*", + "ext-redis": "*", "doctrine/dbal": "^2.13", "psr/log": "^1.1", "ramsey/uuid": "^4.1" }, "require-dev": { - "roave/security-advisories": "dev-latest", "friendsofphp/php-cs-fixer": "^3.0", - "php-amqplib/rabbitmq-bundle": "^2.6.0", - "phpunit/phpunit": "^9.5.4", - "rector/rector": "^0.10.19", - "qossmic/deptrac-shim": "^0.13.0" + "php-amqplib/rabbitmq-bundle": "^2.6", + "phpstan/phpstan": "^1.5", + "phpunit/phpunit": "^9.5", + "qossmic/deptrac-shim": "^0.13", + "rector/rector": "^0.12.21", + "roave/security-advisories": "dev-latest", + "vimeo/psalm": "^4.22" }, "config": { "bin-dir": "bin", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 00000000..1864215f --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + level: 1 + paths: + - ../src + - ../tests + tmpDir: build/.phpstan diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 00000000..adf782f4 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/rector.php b/rector.php index 6a68c12e..6d13c5d6 100644 --- a/rector.php +++ b/rector.php @@ -14,6 +14,7 @@ use Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector; use Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector; use Rector\Core\Configuration\Option; +use Rector\Core\ValueObject\PhpVersion; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\SetList; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; @@ -35,6 +36,8 @@ $configurator->import(SetList::PHP_80); // $configurator->import(SetList::PRIVATIZATION); + $parameters->set(Option::PARALLEL, true); + $parameters->set(Option::SKIP, [ ]); @@ -48,9 +51,14 @@ ]); // Run Rector only on changed files - $parameters->set(Option::ENABLE_CACHE, true); $parameters->set(Option::CACHE_DIR, __DIR__ . '/build/.rector'); + // is your PHP version different from the one your refactor to? [default: your PHP version], uses PHP_VERSION_ID format + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80); + + // Path to phpstan with extensions, that PHPSTan in Rector uses to determine types + $parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, __DIR__ . '/phpstan.neon'); + $services = $configurator->services(); $services->set(UnwrapSprintfOneArgumentRector::class);