From d2194993c5ae7c0fe294845aad29633dcaaa330b Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Wed, 4 Jan 2023 11:54:54 +0100 Subject: [PATCH] Add PHP 8.2 support, drop PHP 8.0 (#19) --- .gitattributes | 19 ++++++++++--------- .github/workflows/integrate.yaml | 21 ++++++--------------- Makefile | 3 ++- README.md | 1 - composer.json | 21 +++++---------------- lib/Config.php | 4 ++++ phpstan-baseline.neon | 6 ++++++ phpstan.neon | 1 + tests/FinalAbstractPublicFixerTest.php | 12 ++++++------ 9 files changed, 40 insertions(+), 48 deletions(-) create mode 100644 phpstan-baseline.neon diff --git a/.gitattributes b/.gitattributes index d57d104..743ce33 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,10 @@ -/.github export-ignore -/tests export-ignore -.gitattributes export-ignore -.gitignore export-ignore -.php-cs-fixer.php export-ignore -Makefile export-ignore -composer-require-checker.json export-ignore -phpstan.neon export-ignore -phpunit.xml export-ignore +/.github export-ignore +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php-cs-fixer.php export-ignore +/Makefile export-ignore +/composer-require-checker.json export-ignore +/phpstan-baseline.neon export-ignore +/phpstan.neon export-ignore +/phpunit.xml export-ignore diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index b942b91..a06f7db 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -15,7 +15,7 @@ jobs: strategy: matrix: php-version: - - "8.0" + - "8.1" steps: - name: "Checkout" @@ -62,8 +62,8 @@ jobs: strategy: matrix: php-version: - - "8.0" - "8.1" + - "8.2" steps: - name: "Checkout" @@ -92,15 +92,7 @@ jobs: - name: "Run tests" timeout-minutes: 3 - run: "vendor/bin/phpunit --coverage-clover=coverage.xml" - - - name: "Send code coverage report to Codecov.io" - if: ${{ matrix.php-version == '8.1' }} - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml - fail_ci_if_error: true + run: "make test" coding-standards: name: "Coding Standards" @@ -110,7 +102,7 @@ jobs: strategy: matrix: php-version: - - "8.0" + - "8.1" steps: - name: "Checkout" @@ -147,7 +139,7 @@ jobs: strategy: matrix: php-version: - - "8.0" + - "8.1" steps: - name: "Checkout" @@ -158,7 +150,6 @@ jobs: with: coverage: "none" php-version: "${{ matrix.php-version }}" - tools: cs2pr - name: "Get composer cache directory" id: composercache @@ -175,4 +166,4 @@ jobs: run: "composer update --no-interaction --no-progress" - name: "Run static analysis" - run: "vendor/bin/phpstan analyse --no-progress --error-format=checkstyle | cs2pr" + run: "vendor/bin/phpstan analyse --no-progress --error-format=github" diff --git a/Makefile b/Makefile index 7aaa153..43345c2 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ all: csfix static-analysis test vendor: composer.json composer update + composer bump touch vendor .PHONY: csfix @@ -11,7 +12,7 @@ csfix: vendor .PHONY: static-analysis static-analysis: vendor - vendor/bin/phpstan analyse + php -d zend.assertions=1 vendor/bin/phpstan analyse .PHONY: test test: vendor diff --git a/README.md b/README.md index 983aa5e..0209337 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![Latest Stable Version](https://img.shields.io/packagist/v/slam/php-cs-fixer-extensions.svg)](https://packagist.org/packages/slam/php-cs-fixer-extensions) [![Downloads](https://img.shields.io/packagist/dt/slam/php-cs-fixer-extensions.svg)](https://packagist.org/packages/slam/php-cs-fixer-extensions) [![Integrate](https://github.com/Slamdunk/php-cs-fixer-extensions/workflows/Integrate/badge.svg?branch=master)](https://github.com/Slamdunk/php-cs-fixer-extensions/actions) -[![Code Coverage](https://codecov.io/gh/Slamdunk/php-cs-fixer-extensions/coverage.svg?branch=master)](https://codecov.io/gh/Slamdunk/php-cs-fixer-extensions?branch=master) [PHP-CS-Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) extensions and configurations diff --git a/composer.json b/composer.json index 4722086..1d7cf72 100644 --- a/composer.json +++ b/composer.json @@ -10,16 +10,15 @@ } ], "require": { - "php": "~8.0.0 || ~8.1.0", + "php": "~8.1.0 || ~8.2.0", "ext-mbstring": "*", "ext-tokenizer": "*", - "friendsofphp/php-cs-fixer": "^3.8.0" + "friendsofphp/php-cs-fixer": "^3.13.2" }, "require-dev": { - "malukenho/mcbumpface": "^1.1.5", - "phpstan/phpstan": "^1.7.6", - "phpstan/phpstan-phpunit": "^1.1.1", - "phpunit/phpunit": "^9.5.20", + "phpstan/phpstan": "^1.9.6", + "phpstan/phpstan-phpunit": "^1.3.3", + "phpunit/phpunit": "^9.5.27", "slam/php-debug-r": "^1.7.0", "slam/phpstan-extensions": "^6.0.0" }, @@ -32,15 +31,5 @@ "psr-4": { "SlamCsFixer\\Tests\\": "tests/" } - }, - "config": { - "allow-plugins": { - "malukenho/mcbumpface": true - } - }, - "extra": { - "mc-bumpface": { - "stripVersionPrefixes": true - } } } diff --git a/lib/Config.php b/lib/Config.php index 1c44936..3fba633 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -29,7 +29,9 @@ final class Config extends PhpCsFixerConfig 'combine_consecutive_unsets' => false, 'comment_to_phpdoc' => false, 'concat_space' => ['spacing' => 'one'], + 'control_structure_braces' => true, 'control_structure_continuation_position' => true, + 'curly_braces_position' => true, 'date_time_create_from_format_call' => true, 'date_time_immutable' => false, 'declare_parentheses' => true, @@ -48,6 +50,7 @@ final class Config extends PhpCsFixerConfig 'native_function_invocation' => ['include' => ['@internal']], 'no_blank_lines_before_namespace' => false, 'no_multiline_whitespace_around_double_arrow' => false, + 'no_multiple_statements_per_line' => true, 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], 'not_operator_with_space' => false, 'not_operator_with_successor_space' => true, @@ -74,6 +77,7 @@ final class Config extends PhpCsFixerConfig 'simplified_null_return' => false, 'single_line_throw' => false, 'space_after_semicolon' => true, + 'statement_indentation' => true, 'static_lambda' => false, 'unary_operator_spaces' => false, 'use_arrow_functions' => false, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..1b3fa75 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,6 @@ +parameters: + ignoreErrors: + - + message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertNotEmpty\\(\\) with false will always evaluate to false\\.$#" + count: 1 + path: tests/ConfigTest.php diff --git a/phpstan.neon b/phpstan.neon index fa10ae8..fa91e0c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/slam/phpstan-extensions/conf/slam-rules.neon + - phpstan-baseline.neon parameters: level: 5 diff --git a/tests/FinalAbstractPublicFixerTest.php b/tests/FinalAbstractPublicFixerTest.php index 5b4dcc3..df0a578 100644 --- a/tests/FinalAbstractPublicFixerTest.php +++ b/tests/FinalAbstractPublicFixerTest.php @@ -41,14 +41,14 @@ private static function f6(){} $fixed = \str_replace('public function', 'final public function', $fixed); return [ - 'final-class' => [" [" [' [" [" [' [" [' [" [' [ + 'abstract-class' => [ "