diff --git a/.github/workflows/basics.yml b/.github/workflows/basics.yml index 1631ec74..9102aef8 100644 --- a/.github/workflows/basics.yml +++ b/.github/workflows/basics.yml @@ -10,6 +10,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: checkcs: name: 'Basic CS and QA checks' @@ -37,16 +43,16 @@ jobs: - name: 'Composer: adjust dependencies' run: | # The sniff stage doesn't run the unit tests, so no need for PHPUnit. - composer remove --no-update --dev phpunit/phpunit --no-scripts + composer remove --no-update --dev phpunit/phpunit --no-scripts --no-interaction # Using PHPCS `master` as an early detection system for bugs upstream. - composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master" + composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master" --no-interaction # Using WPCS `master` (=stable). This can be changed back to `dev-develop` after the WPCS 3.0.0 release. - composer require --no-update --no-scripts wp-coding-standards/wpcs:"dev-master" + composer require --no-update --no-scripts wp-coding-standards/wpcs:"dev-master" --no-interaction # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 - name: Install xmllint run: sudo apt-get install --no-install-recommends -y libxml2-utils diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index ca98c0d5..035ebb0f 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -10,6 +10,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: #### QUICK TEST STAGE #### # This is a much quicker test which only runs the unit tests and linting against low/high @@ -24,13 +30,13 @@ jobs: phpcs_version: 'dev-master' wpcs_version: 'dev-master' - php_version: 'latest' - phpcs_version: '3.6.0' + phpcs_version: '3.6.2' wpcs_version: '2.3.0' - php_version: '5.4' phpcs_version: 'dev-master' wpcs_version: '2.3.0' - php_version: '5.4' - phpcs_version: '3.6.0' + phpcs_version: '3.6.2' wpcs_version: 'dev-master' name: "QTest${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php_version }} - PHPCS ${{ matrix.phpcs_version }} - WPCS ${{ matrix.wpcs_version }}" @@ -47,7 +53,7 @@ jobs: if [ "${{ matrix.phpcs_version }}" != "dev-master" ]; then echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' else - echo '::set-output name=PHP_INI::error_reporting=E_ALL, display_errors=On' + echo '::set-output name=PHP_INI::error_reporting=-1, display_errors=On' fi - name: Install PHP @@ -60,20 +66,20 @@ jobs: - name: 'Composer: adjust dependencies' run: | # Set the PHPCS version to test against. - composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" + composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-interaction # Set the WPCS version to test against. - composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" + composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-interaction # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies - normal if: ${{ startsWith( matrix.php_version, '8' ) == false && matrix.php_version != 'latest' }} - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 # For the PHP 8.0 and higher, we need to install with ignore platform reqs as not all dependencies allow it. - name: Install Composer dependencies - with ignore platform if: ${{ startsWith( matrix.php_version, '8' ) || matrix.php_version == 'latest' }} - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: composer-options: --ignore-platform-reqs @@ -84,5 +90,12 @@ jobs: if: matrix.phpcs_version == 'dev-master' run: composer lint - - name: Run the unit tests + - name: Run the unit tests - PHP 5.4 - 8.0 + if: ${{ matrix.php_version < '8.1' && matrix.php_version != 'latest' }} run: composer test + + - name: Run the unit tests - PHP 8.1+ + if: ${{ matrix.php_version >= '8.1' || matrix.php_version == 'latest'}} + run: composer test -- --no-configuration --dont-report-useless-tests + env: + PHPCS_IGNORE_TESTS: 'PHPCompatibility,WordPress' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a57d163b..35cdb925 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,12 @@ on: # Allow manually triggering the workflow. workflow_dispatch: +# Cancels all previous workflow runs for the same branch that have not yet completed. +concurrency: + # The concurrency group contains the workflow name and the branch name. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: #### TEST STAGE #### test: @@ -28,8 +34,8 @@ jobs: # Note: while WPCS 3.0.0 is under development, the matrix will use `dev-master`. # Once it has been released and YoastCS has been made compatible, the matrix should switch (back) # WPCS `dev-master` to `dev-develop`. - php_version: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] - phpcs_version: ['3.6.0', 'dev-master'] + php_version: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + phpcs_version: ['3.6.2', 'dev-master'] wpcs_version: ['2.3.0', 'dev-master'] experimental: [false] @@ -37,7 +43,7 @@ jobs: # Experimental builds. These are allowed to fail. # PHP nightly - - php_version: '8.1' + - php_version: '8.2' phpcs_version: 'dev-master' wpcs_version: 'dev-master' experimental: true @@ -69,7 +75,7 @@ jobs: if [[ "${{ matrix.phpcs_version }}" != "dev-master" && "${{ matrix.phpcs_version }}" != "4.0.x-dev" ]]; then echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On' else - echo '::set-output name=PHP_INI::error_reporting=E_ALL, display_errors=On' + echo '::set-output name=PHP_INI::error_reporting=-1, display_errors=On' fi - name: Install PHP @@ -93,25 +99,25 @@ jobs: - name: 'Composer: adjust dependencies' run: | # Set the PHPCS version to test against. - composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" + composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-interaction # Set the WPCS version to test against. - composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" + composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}" --no-interaction - name: 'Composer: conditionally remove PHPCSDevtools' if: ${{ startsWith( matrix.phpcs_version, '4' ) }} # Remove devtools as it will not (yet) install on PHPCS 4.x. - run: composer remove --no-update --dev phpcsstandards/phpcsdevtools + run: composer remove --no-update --dev phpcsstandards/phpcsdevtools --no-interaction # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-composer-dependencies - name: Install Composer dependencies - normal if: ${{ startsWith( matrix.php_version, '8' ) == false }} - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 # For the PHP 8/"nightly", we need to install with ignore platform reqs as we're still using PHPUnit 7. - name: Install Composer dependencies - with ignore platform if: ${{ startsWith( matrix.php_version, '8' ) }} - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 with: composer-options: --ignore-platform-reqs @@ -125,11 +131,11 @@ jobs: run: composer lint -- --checkstyle | cs2pr - name: Run the unit tests - PHP 5.4 - 8.0 - if: ${{ matrix.php_version != '8.1' }} + if: ${{ matrix.php_version < '8.1' }} run: composer test - name: Run the unit tests - PHP 8.1 - if: ${{ matrix.php_version == '8.1' }} + if: ${{ matrix.php_version >= '8.1' }} run: composer test -- --no-configuration --dont-report-useless-tests env: PHPCS_IGNORE_TESTS: 'PHPCompatibility,WordPress' diff --git a/CHANGELOG.md b/CHANGELOG.md index 197e5967..a89d28a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/). +### [2.2.1] - 2022-02-22 + +#### Changed +* Composer: Supported version of [PHP_CodeSniffer] has been changed from `^3.6.0` to `^3.6.2`. +* Composer: Supported version of [PHPCompatibilityWP] has been changed from `^2.1.0` to `^2.1.3`. +* Composer: Supported version of [PHP Parallel Lint] has been changed from `^1.3.1` to `^1.3.2`. +* Composer: Supported version of [PHP Console Highlighter] has been changed from `^0.5.0` to `^1.0.0`. +* Readme: Updated installation instructions for compatibility with Composer 2.2+ and other minor improvements. +* Various housekeeping. + + ### [2.2.0] - 2021-09-22 #### Added @@ -60,7 +71,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a C #### Changed * PHPCS: The default value for the `minimum_supported_wp_version` property which is used by various WPCS sniffs has been updated to WP `5.4` (was `5.3`). -* Composer: Supported version of the [DealerDirect Composer PHPCS plugin] has been changed to allow for the newly released `0.7.0` version which adds support for Composer 2.0. +* Composer: Supported version of the [Composer PHPCS plugin] has been changed to allow for the newly released `0.7.0` version which adds support for Composer 2.0. Note: this requirement is flexible to prevent conflicts with included standards which may include the plugin as well. * Travis: improved testing against the upcoming PHP 8.0. * Various housekeeping. @@ -80,7 +91,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a C ### [2.0.1] - 2020-02-06 #### Changed -* Composer: Supported version of the [DealerDirect Composer PHPCS plugin] has been changed from `^0.5.0` to `^0.5 || ^0.6`. +* Composer: Supported version of the [Composer PHPCS plugin] has been changed from `^0.5.0` to `^0.5 || ^0.6`. Note: this requirement is flexible to prevent conflicts with included standards which may include the plugin as well. * Various housekeeping. @@ -136,7 +147,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a C * PHPCS: The `PSR12.Files.OpenTag` sniff. Enforces that a PHP open tag is on a line by itself in PHP-only files. * PHPCS: A `CustomPrefixesTrait` to handle checking names against a list of custom prefixes. -* Composer: `lint` script which uses the [Parallel-Lint] package for faster and more readable linting results. +* Composer: `lint` script which uses the [PHP Parallel Lint] package for faster and more readable linting results. #### Changed * :warning: PHPCS: `Yoast.Files.FileName` sniff: the public `$prefixes` property, which can be used to indicate which _prefixes_ should be stripped of a class name when translating it to a file name, has been renamed to `$oo_prefixes`. @@ -233,7 +244,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a C * PHPCS: New `Yoast.Commenting.CodeCoverageIgnoreDeprecated` sniff. This sniff verifies that functions which have a `@deprecated` tag in the function docblock, also have a `@codeCoverageIgnore` tag in the same docblock. * PHPCS: Added XSD schema tags to the ruleset. -* Composer: requirement of the [DealerDirect Composer PHPCS plugin] at version `^0.5.0`. +* Composer: requirement of the [Composer PHPCS plugin] at version `^0.5.0`. This means that - in most cases - projects which `require(-dev)` YoastCS, will no longer need to have the plugin in their own `composer.json` and will still get the benefit of it. * Travis: Validation of the ruleset against the PHPCS XSD schema. * Travis: Testing of the code against PHP 7.3. @@ -249,7 +260,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a C #### Removed * PHPCS: Minor housekeeping: removed some unused code. -* Composer: `suggest` section. The [DealerDirect Composer PHPCS plugin] is now included in the `require` section. +* Composer: `suggest` section. The [Composer PHPCS plugin] is now included in the `require` section. #### Fixed * PHPCS: Various fixes to the `Yoast.Files.TestDoubles` sniff. @@ -268,7 +279,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a C * PHPCS: The `PSR2.Methods.FunctionClosingBrace` sniff to the YoastCS ruleset. * PHPCS: The `PSR12.Keywords.ShortFormTypeKeywords` sniff, as introduced in PHP_CodeSniffer 3.3.0, to the YoastCS ruleset. * Composer: `roave/security-advisories` dependency to prevent dependencies with known security issues from being installed. -* Composer: An explanation about the [DealerDirect Composer PHPCS plugin] dependency suggestion this package makes. +* Composer: An explanation about the [Composer PHPCS plugin] dependency suggestion this package makes. * Composer: `--dev` requirement of the [PHPCompatibility] library at version `^8.2.0`. #### Changed @@ -305,7 +316,7 @@ This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a C * PHPCS: An exclusion for the `WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition` error code. * PHPCS: An exclusion for the `WordPress.PHP.StrictInArray.FoundNonStrictFalse` error code. * Composer: Repository `type` indicator for compatibility with Composer plugins which handle the setting of the PHP_CodeSniffer `installed_paths` directive. -* Composer: Suggest requiring the [DealerDirect Composer PHPCS plugin], i.e. `dealerdirect/phpcodesniffer-composer-installer`, for handling the PHP_CodeSniffer `installed_paths` directive at version `^0.4.3`. +* Composer: Suggest requiring the [Composer PHPCS plugin], i.e. `dealerdirect/phpcodesniffer-composer-installer`, for handling the PHP_CodeSniffer `installed_paths` directive at version `^0.4.3`. * Travis: Validation and CS check of the XML files. * Travis: Testing of the repo against PHP 7.2. * Travis: Checking of the code style of the YoastCS native PHP files. @@ -434,15 +445,16 @@ This project adheres to [Semantic Versioning](https://semver.org/) and [Keep a C Initial public release as a stand-alone package. -[PHP_CodeSniffer]: https://github.com/squizlabs/PHP_CodeSniffer/releases -[WordPressCS]: https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/CHANGELOG.md -[PHPCompatibilityWP]: https://github.com/PHPCompatibility/PHPCompatibilityWP#changelog -[PHPCompatibility]: https://github.com/PHPCompatibility/PHPCompatibility/blob/master/CHANGELOG.md -[PHP Mess Detector]: https://github.com/phpmd/phpmd/blob/master/CHANGELOG -[DealerDirect Composer PHPCS plugin]: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases -[Parallel-Lint]: https://packagist.org/packages/jakub-onderka/php-parallel-lint -[PHP Parallel Lint]: https://github.com/php-parallel-lint/PHP-Parallel-Lint/ +[PHP_CodeSniffer]: https://github.com/squizlabs/PHP_CodeSniffer/releases +[WordPressCS]: https://github.com/WordPress/WordPress-Coding-Standards/blob/develop/CHANGELOG.md +[PHPCompatibilityWP]: https://github.com/PHPCompatibility/PHPCompatibilityWP#changelog +[PHPCompatibility]: https://github.com/PHPCompatibility/PHPCompatibility/blob/master/CHANGELOG.md +[PHP Mess Detector]: https://github.com/phpmd/phpmd/blob/master/CHANGELOG +[Composer PHPCS plugin]: https://github.com/PHPCSStandards/composer-installer/releases +[PHP Parallel Lint]: https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases +[PHP Console Highlighter]: https://github.com/php-parallel-lint/PHP-Console-Highlighter/releases +[2.2.1]: https://github.com/Yoast/yoastcs/compare/2.2.0...2.2.1 [2.2.0]: https://github.com/Yoast/yoastcs/compare/2.1.0...2.2.0 [2.1.0]: https://github.com/Yoast/yoastcs/compare/2.0.2...2.1.0 [2.0.2]: https://github.com/Yoast/yoastcs/compare/2.0.1...2.0.2 diff --git a/README.md b/README.md index 295626de..ddba2d04 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ Composer will automatically install dependencies, register standards paths, and To include standards as part of a project require them as development dependencies: ```bash -composer require --dev yoast/yoastcs:^2.0 +composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true +composer require --dev yoast/yoastcs:"^2.0" ``` Composer will automatically install dependencies and register the YoastCS and other external standards with PHP_CodeSniffer. @@ -42,7 +43,7 @@ Typically, (a variation on) the following snippet would be added to the `compose ```json "scripts" : { "lint": [ - "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git" + "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --show-deprecated --exclude vendor --exclude .git" ] } ``` diff --git a/composer.json b/composer.json index 6b6febd8..8bc33cad 100644 --- a/composer.json +++ b/composer.json @@ -23,12 +23,12 @@ }, "require": { "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.6.0", + "squizlabs/php_codesniffer": "^3.6.2", "wp-coding-standards/wpcs": "^2.3.0", - "phpcompatibility/phpcompatibility-wp": "^2.1.0", + "phpcompatibility/phpcompatibility-wp": "^2.1.3", "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6.2 || ^0.7", - "php-parallel-lint/php-parallel-lint": "^1.3.1", - "php-parallel-lint/php-console-highlighter": "^0.5.0" + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "php-parallel-lint/php-console-highlighter": "^1.0.0" }, "require-dev": { "phpcompatibility/php-compatibility": "^9.3.5", @@ -36,6 +36,11 @@ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0", "phpcsstandards/phpcsdevtools": "^1.0" }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, "minimum-stability": "dev", "prefer-stable": true, "scripts": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a3416a92..0aa18327 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,6 +5,10 @@ backupGlobals="true" beStrictAboutTestsThatDoNotTestAnything="false" colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + convertDeprecationsToExceptions="true" forceCoversAnnotation="true" >