diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml new file mode 100644 index 0000000..27e972b --- /dev/null +++ b/.github/workflows/quality-assurance.yml @@ -0,0 +1,34 @@ +name: 'PHP Quality Assurance' +on: + pull_request: + paths: + - '**.php' + - 'composer.*' + - 'phpcs.*' + - 'phpstan.*' +jobs: + lint-php: + uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main + strategy: + matrix: + php: + - '7.4' + - '8.0' + - '8.1' + - '8.2' + - '8.3' + - '8.4' + with: + PHP_VERSION: '${{ matrix.php }}' + coding-standards-php: + uses: inpsyde/reusable-workflows/.github/workflows/coding-standards-php.yml@main + secrets: + COMPOSER_AUTH_JSON: '${{secrets.PACKAGIST_AUTH_JSON}}' + with: + PHP_VERSION: '8.4' + static-analysis-php: + uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main + secrets: + COMPOSER_AUTH_JSON: '${{secrets.PACKAGIST_AUTH_JSON}}' + with: + PHP_VERSION: '8.4' diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml deleted file mode 100644 index 57e4a83..0000000 --- a/.github/workflows/static-analysis.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Static Analysis - -on: - push: - paths: - - '**workflows/static-analysis.yml' - - '**.php' - - '**phpcs.xml.dist' - - '**psalm.xml' - pull_request: - paths: - - '**workflows/static-analysis.yml' - - '**.php' - - '**phpcs.xml.dist' - - '**psalm.xml' - workflow_dispatch: - inputs: - jobs: - required: true - type: choice - default: 'Run all' - description: 'Choose jobs to run' - options: - - 'Run all' - - 'Run PHPCS only' - - 'Run Psalm only' - - 'Run lint only' - -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true - -jobs: - lint: - if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run lint only')) }} - uses: inpsyde/reusable-workflows/.github/workflows/lint-php.yml@main - strategy: - matrix: - php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] - with: - PHP_VERSION: ${{ matrix.php }} - LINT_ARGS: '-e php --colors --show-deprecated ./inc ./src' - - coding-standards-analysis: - if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run PHPCS only')) }} - uses: inpsyde/reusable-workflows/.github/workflows/coding-standards-php.yml@main - with: - PHP_VERSION: '8.3' - - static-code-analysis: - if: ${{ (github.event_name != 'workflow_dispatch') || ((github.event.inputs.jobs == 'Run all') || (github.event.inputs.jobs == 'Run Psalm only')) }} - uses: inpsyde/reusable-workflows/.github/workflows/static-analysis-php.yml@main - strategy: - matrix: - php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] - with: - PHP_VERSION: ${{ matrix.php }} - PSALM_ARGS: --output-format=github --no-suggestions --no-cache --no-diff \ No newline at end of file diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 3dc1b26..0371924 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -23,9 +23,15 @@ jobs: strategy: fail-fast: false matrix: - php-ver: [ '7.4', '8.0', '8.1', '8.2', '8.3' ] + php-ver: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] wp-ver: [ '5.9', '6.0', '6.1', '6.2', '6.3', '6.4', '6' ] exclude: + - php-ver: '7.4' + wp-ver: '6.3' + - php-ver: '7.4' + wp-ver: '6.4' + - php-ver: '7.4' + wp-ver: '6' - php-ver: '8.2' wp-ver: '5.9' - php-ver: '8.3' @@ -40,6 +46,13 @@ jobs: wp-ver: '6.2' - php-ver: '8.3' wp-ver: '6.3' + - php-ver: '8.4' + wp-ver: '6.3' + include: + - php-ver: '7.4' + composer: '--ignore-platform-req=php' + - php-ver: '8.0' + composer: '--ignore-platform-req=php' steps: - name: Checkout uses: actions/checkout@v4 @@ -53,11 +66,14 @@ jobs: - name: Adjust dependencies in 'composer.json' run: | - composer remove roots/wordpress-no-content inpsyde/php-coding-standards vimeo/psalm --dev --no-update - composer require "roots/wordpress-no-content:~${{ matrix.wp-ver }}.0" --dev --no-update + composer remove roots/wordpress-no-content inpsyde/php-coding-standards vimeo/psalm syde/phpcs phpstan/phpstan --dev --no-update + composer require "roots/wordpress-no-content:~${{ matrix.wp-ver }}.0" --dev - name: Install dependencies uses: ramsey/composer-install@v3 + with: + dependency-versions: ${{ matrix.dependency-versions }} + composer-options: ${{ matrix.composer || '' }} - name: Run unit tests run: ./vendor/bin/phpunit --no-coverage diff --git a/README.md b/README.md index ca98e33..5511700 100644 --- a/README.md +++ b/README.md @@ -354,6 +354,7 @@ It is tested and guaranteed to work with WP 5.9+, but _should_ work, at least, w --- -## License +## Copyright and License + +This package is [free software](https://www.gnu.org/philosophy/free-sw.en.html) distributed under the terms of the GNU General Public License version 2 or (at your option) any later version. For the full license, see [LICENSE](./LICENSE). -This repository is free software released under the terms of the GNU General Public License version 2 or (at your option) any later version. See [LICENSE](./LICENSE) for the complete license. diff --git a/composer.json b/composer.json index 5be50f5..ed34723 100644 --- a/composer.json +++ b/composer.json @@ -18,13 +18,17 @@ ], "minimum-stability": "dev", "require": { - "php": ">=7.4 < 8.4" + "php": ">=7.4 < 8.5" }, "require-dev": { - "roots/wordpress-no-content": ">=6.5.3", + "roots/wordpress-no-content": "dev-main", "phpunit/phpunit": "^9.6.19", - "inpsyde/php-coding-standards": "^2", - "vimeo/psalm": "^5.24.0" + "phpstan/phpstan": "2.2.x-dev", + "phpstan/phpstan-mockery": "2.0.x-dev", + "phpstan/phpstan-deprecation-rules": "2.0.x-dev", + "php-stubs/wp-cli-stubs": "dev-master", + "syde/phpcs": "dev-main", + "php-stubs/wordpress-stubs": "^6.9" }, "autoload": { "psr-4": { @@ -54,7 +58,7 @@ }, "scripts": { "cs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs", - "psalm": "@php ./vendor/vimeo/psalm/psalm --no-suggestions --report-show-info=false --find-unused-psalm-suppress --no-diff --no-cache --no-file-cache --output-format=compact", + "stan": "@php ./vendor/bin/phpstan analyse --no-progress --memory-limit=1G", "tests": "@php ./vendor/phpunit/phpunit/phpunit --no-coverage", "qa": [ "@cs", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 8d20811..73422da 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,34 +1,28 @@ + + + + ./inc/ ./src/ ./tests/ - - - - + - - - - - + - ./tests/ + */tests/* - - ./tests/ - - - ./tests/ + + + + + + + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..e7cd4d8 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,12 @@ +includes: + - vendor/phpstan/phpstan-deprecation-rules/rules.neon + - vendor/phpstan/phpstan-mockery/extension.neon +parameters: + level: 1 + scanFiles: + - vendor/php-stubs/wp-cli-stubs/wp-cli-stubs.php + - vendor/php-stubs/wordpress-stubs/wordpress-stubs.php + paths: + - src/ + - inc/ + treatPhpDocTypesAsCertain: false diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index 1307485..0000000 --- a/psalm.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/Functions.php b/src/Functions.php index 741a15c..e6d6329 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -511,7 +511,7 @@ private static function matchClosureParams(array $params, array $targetArgs): bo * @param array $array * @return list{bool, array} * - * phpcs:disable Inpsyde.CodeQuality.NestingLevel + * phpcs:disable SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh */ private static function normalizeTargetArgsList(array $array): array { diff --git a/tests/cases/RemoveClosureHookTest.php b/tests/cases/RemoveClosureHookTest.php index 66699c9..a50ac16 100644 --- a/tests/cases/RemoveClosureHookTest.php +++ b/tests/cases/RemoveClosureHookTest.php @@ -5,7 +5,6 @@ namespace Inpsyde\ObjectHooksRemover\Tests; use function Inpsyde\remove_closure_hook; -use function Inpsyde\remove_instance_hook; /** * @runTestsInSeparateProcesses