From 3bec4d29754294b42e79518680ac483a179c1bc8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 21 Oct 2025 23:47:50 +0200 Subject: [PATCH 1/4] PHPCompatibilitySymfonyPolyfillPHP56: update ruleset for PHPCompatibility 10.0-alpha1 Looks like one function call would at the very least run into a warning: https://3v4l.org/v3mZE Having said that, it would need a combination of Mbstring function overload being into effect + Mbstring not being available for this warning to be hit, which is probably why nobody ever reported it to Symfony. All in all, not our concern, but a bug in the Polyfill, so let's just ignore it. --- PHPCompatibilitySymfonyPolyfillPHP56/ruleset.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PHPCompatibilitySymfonyPolyfillPHP56/ruleset.xml b/PHPCompatibilitySymfonyPolyfillPHP56/ruleset.xml index e8bb6e2..203d715 100644 --- a/PHPCompatibilitySymfonyPolyfillPHP56/ruleset.xml +++ b/PHPCompatibilitySymfonyPolyfillPHP56/ruleset.xml @@ -11,4 +11,11 @@ + + + + /polyfill-util/BinaryNoFuncOverload\.php$ + + From fb54eaf5c0ee8597b08e100bf8bee8e5b6ddd9ff Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 21 Oct 2025 21:59:43 +0200 Subject: [PATCH 2/4] PHPCompatibilitySymfonyPolyfillPHP72: update ruleset for PHPCompatibility 10.0-alpha1 Two of the polyfilled functions have since been deprecated by PHP itself. As they are polyfilled by the Symfony PHP 7.2 polyfill, we can ignore the deprecation though. Includes bug fix for a faulty test. --- PHPCompatibilitySymfonyPolyfillPHP72/ruleset.xml | 2 ++ Test/SymfonyPolyfillPHP72Test.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/PHPCompatibilitySymfonyPolyfillPHP72/ruleset.xml b/PHPCompatibilitySymfonyPolyfillPHP72/ruleset.xml index e6e9a00..c5fc9a8 100644 --- a/PHPCompatibilitySymfonyPolyfillPHP72/ruleset.xml +++ b/PHPCompatibilitySymfonyPolyfillPHP72/ruleset.xml @@ -18,6 +18,8 @@ + + diff --git a/Test/SymfonyPolyfillPHP72Test.php b/Test/SymfonyPolyfillPHP72Test.php index 151b107..233ad49 100644 --- a/Test/SymfonyPolyfillPHP72Test.php +++ b/Test/SymfonyPolyfillPHP72Test.php @@ -2,7 +2,7 @@ /* * Test file to run PHP_CodeSniffer against to make sure the polyfills are correctly excluded. */ -$a = PHP_OS_FAMILY ? utf8_encode($b) : utf_decode($b); +$a = PHP_OS_FAMILY ? utf8_encode($b) : utf8_decode($b); $c = stream_isatty(); $d = sapi_windows_vt100_support(); From 46a6b2b9a9d95af825399cd36264d2885944b75f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 21 Oct 2025 23:49:30 +0200 Subject: [PATCH 3/4] PHPCompatibilitySymfonyPolyfillPHP80: update ruleset for PHPCompatibility 10.0-alpha1 As of PHPCompatibility 10.0.0, we detect and handle the use of PHP 8.0 attributes (though I expect _how_ to still change a little more). In this case, an attribute is applied to the polyfill for the `Attribute` class, so we need to ignore that attribute ;-) --- PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml b/PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml index a680612..338c2ab 100644 --- a/PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml +++ b/PHPCompatibilitySymfonyPolyfillPHP80/ruleset.xml @@ -22,4 +22,9 @@ + + + /polyfill-php80/Resources/stubs/Attribute\.php$ + + From a4bf54bf09336a067c4b0e07db4e6e4daae80d7e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 30 Apr 2020 22:34:29 +0200 Subject: [PATCH 4/4] Version 2.0.0-alpha1 / Update for PHPCompatibility 10.0.0-alpha1 This update accounts for the following changes: * Composer: - Update the version for the PHPCompatibility dependency. The `@dev` version number suffix should ensure that the PHPCompatibility 10.0.0-alpha1 version can be installed, even if the project minimum stability does not specifically allow for dev versions. - Remove the DealerDirect Composer PHPCS plugin dependency. This plugin will now automatically be installed as it is a dependency of PHPCSUtils and therefore of PHPCompatibility itself. Not having it set as an explicit dependency here, will prevent potential future conflicts with the supported versions of the plugin. - Removed the `suggest` section. The DealerDirect plugin no longer needs to be suggested and after two years, people should have gotten the message about using the `roave/security-advisories`. * Readme: - Updated the minimum PHP and PHPCS requirements. - Updated the installation instructions for the 2.0.0-alpha1 release (being a dev release). - Updated the installation instructions to no longer mention adding a Composer plugin to sort out the PHPCS `installed_paths`. - Added upgrade instructions. - Added section about funding. - Use link list for links used multiple times. - Minor other tweaks after critical read-through of the README. * CI: - Continue testing against `dev-develop`. - Prevent builds failing on low PHP versions on the recommendation to use a more recent PHP version. --- .github/workflows/ci.yml | 46 ++++++------- README.md | 144 ++++++++++++++++++++++----------------- composer.json | 11 +-- 3 files changed, 109 insertions(+), 92 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c4b0aa..488150c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,7 +83,7 @@ jobs: include: - php: '7.4' - phpcompat: 'dev-develop as 9.99.99' + phpcompat: 'dev-develop as 10.99.99' experimental: true name: "Test: PHP ${{ matrix.php }} - PHPCompat ${{ matrix.phpcompat }}" @@ -133,49 +133,49 @@ jobs: # Make sure that known polyfills don't trigger any errors. - name: Test the rulesets run: | - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP54Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP54 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP55Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP55 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP56Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP56 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP70Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP70 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP71Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP71 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP72Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP72 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP73Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP73 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP74Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP74 --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP54Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP54 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP55Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP55 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP56Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP56 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP70Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP70 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP71Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP71 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP72Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP72 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP73Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP73 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP74Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP74 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- - name: Test the PHP 8.0 ruleset # The PHP 8.0 polyfill has a minimum PHP requirement of PHP 7.1. if: ${{ matrix.php != '5.4' }} run: | - vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP80Test.php --standard=PHPCompatibilitySymfonyPolyfillPHP80 --runtime-set testVersion 7.1- + vendor/bin/phpcs -ps ./Test/SymfonyPolyfillPHP80Test.php --exclude=PHPCompatibility.Upgrade.LowPHP --standard=PHPCompatibilitySymfonyPolyfillPHP80 --runtime-set testVersion 7.1- # Check that the rulesets don't throw unnecessary errors for the compat libraries themselves. # Note: the polyfills for PHP 5.4 - 7.1 have been decoupled from the monorepo at version 1.19. - # The polyfills for PHP 7.2 has been decoupled from the monorepo at version 1.30. + # The polyfills for PHP 7.2 have been decoupled from the monorepo at version 1.30. # These are no longer updated. - name: Test running against the polyfills - polyfills 5.4-7.1 run: | - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php54/ --standard=PHPCompatibilitySymfonyPolyfillPHP54 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php55/ --standard=PHPCompatibilitySymfonyPolyfillPHP55 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php56/ ./vendor/symfony/polyfill-util/ --standard=PHPCompatibilitySymfonyPolyfillPHP56 --runtime-set testVersion 5.3- --ignore=*/polyfill-util/TestListener* - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php70/ --standard=PHPCompatibilitySymfonyPolyfillPHP70 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php71/ --standard=PHPCompatibilitySymfonyPolyfillPHP71 --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php54/ --standard=PHPCompatibilitySymfonyPolyfillPHP54 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php55/ --standard=PHPCompatibilitySymfonyPolyfillPHP55 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php56/ ./vendor/symfony/polyfill-util/ --standard=PHPCompatibilitySymfonyPolyfillPHP56 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- --ignore=*/polyfill-util/TestListener* + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php70/ --standard=PHPCompatibilitySymfonyPolyfillPHP70 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php71/ --standard=PHPCompatibilitySymfonyPolyfillPHP71 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- # The polyfills for PHP 7.2 and higher are compatible with PHP 5.3+ at version 1.19. - name: "Test running against the polyfills - polyfills 7.2- (v1.19)" if: ${{ matrix.php == '5.4' }} run: | - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php72/ --standard=PHPCompatibilitySymfonyPolyfillPHP72 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php73/ --standard=PHPCompatibilitySymfonyPolyfillPHP73 --runtime-set testVersion 5.3- - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php74/ --standard=PHPCompatibilitySymfonyPolyfillPHP74 --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php72/ --standard=PHPCompatibilitySymfonyPolyfillPHP72 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php73/ --standard=PHPCompatibilitySymfonyPolyfillPHP73 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php74/ --standard=PHPCompatibilitySymfonyPolyfillPHP74 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 5.3- # The polyfills for PHP 7.2 and higher are compatible with PHP 7.1+ at version 1.30. - name: "Test running against the polyfills - polyfills 7.2- (v1.30)" if: ${{ matrix.php == '7.1' }} run: | - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php72/ --standard=PHPCompatibilitySymfonyPolyfillPHP72 --runtime-set testVersion 7.1- - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php73/ --standard=PHPCompatibilitySymfonyPolyfillPHP73 --runtime-set testVersion 7.1- - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php74/ --standard=PHPCompatibilitySymfonyPolyfillPHP74 --runtime-set testVersion 7.1- - vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php80/ --standard=PHPCompatibilitySymfonyPolyfillPHP80 --runtime-set testVersion 7.1- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php72/ --standard=PHPCompatibilitySymfonyPolyfillPHP72 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 7.1- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php73/ --standard=PHPCompatibilitySymfonyPolyfillPHP73 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 7.1- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php74/ --standard=PHPCompatibilitySymfonyPolyfillPHP74 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 7.1- + vendor/bin/phpcs -ps ./vendor/symfony/polyfill-php80/ --standard=PHPCompatibilitySymfonyPolyfillPHP80 --exclude=PHPCompatibility.Upgrade.LowPHP --runtime-set testVersion 7.1- # The polyfills for PHP 7.3 and higher are compatible with PHP 7.2+ at the current version. - name: "Test running against the polyfills - polyfills 7.3- (current)" diff --git a/README.md b/README.md index 2e3b1ba..6fe83e6 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,32 @@ # PHPCompatibilitySymfony -[![Latest Stable Version](https://img.shields.io/packagist/v/phpcompatibility/phpcompatibility-symfony?label=stable)](https://packagist.org/packages/phpcompatibility/phpcompatibility-symfony) -[![Latest Unstable Version](https://img.shields.io/badge/unstable-dev--develop-e68718.svg?maxAge=2419200)](https://packagist.org/packages/phpcompatibility/phpcompatibility-symfony) +[![Latest Stable Version](https://img.shields.io/packagist/v/phpcompatibility/phpcompatibility-symfony?label=stable)][packagist] +[![Latest Unstable Version](https://img.shields.io/badge/unstable-dev--develop-e68718.svg?maxAge=2419200)][packagist] [![License](https://img.shields.io/github/license/PHPCompatibility/PHPCompatibilitySymfony?color=00a7a7)](https://github.com/PHPCompatibility/PHPCompatibilitySymfony/blob/master/LICENSE) [![Build Status](https://github.com/PHPCompatibility/PHPCompatibilitySymfony/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/PHPCompatibility/PHPCompatibilitySymfony/actions/workflows/ci.yml) -Using PHPCompatibilitySymfony, you can analyse the codebase of a project using any of the [Symfony polyfill libraries](https://github.com/symfony?utf8=?&q=polyfill), for PHP cross-version compatibility. +Using PHPCompatibilitySymfony, you can analyse the codebase of a project using any of the [Symfony polyfill libraries], for PHP cross-version compatibility. ## What's in this repo ? A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Symfony polyfill libraries. -These rulesets prevent false positives from the [PHPCompatibility standard](https://github.com/PHPCompatibility/PHPCompatibility) by excluding back-fills and poly-fills which are provided by those libraries. - -| Symfony Polyfill Library | Corresponding PHPCompatibility Ruleset | Includes | -|--------------------------|----------------------------------------|-------------------------------------------| -| [`polyfill-php54`] | `PHPCompatibilitySymfonyPolyfillPHP54` | | -| [`polyfill-php55`] | `PHPCompatibilitySymfonyPolyfillPHP55` | [`PHPCompatibilityPasswordCompat`] | -| [`polyfill-php56`] | `PHPCompatibilitySymfonyPolyfillPHP56` | | -| [`polyfill-php70`] | `PHPCompatibilitySymfonyPolyfillPHP70` | [`PHPCompatibilityParagonieRandomCompat`] | -| [`polyfill-php71`] | `PHPCompatibilitySymfonyPolyfillPHP71` | | -| [`polyfill-php72`] | `PHPCompatibilitySymfonyPolyfillPHP72` | | -| [`polyfill-php73`] | `PHPCompatibilitySymfonyPolyfillPHP73` | | -| [`polyfill-php74`] | `PHPCompatibilitySymfonyPolyfillPHP74` | | -| [`polyfill-php80`] | `PHPCompatibilitySymfonyPolyfillPHP80` | | - +These rulesets prevent false positives from the [PHPCompatibility standard][PHPCompatibility] by excluding back-fills and polyfills which are provided by those libraries. + +| Symfony Polyfill Library | Corresponding PHPCompatibility Ruleset | Includes | +|--------------------------|----------------------------------------|----------------------------------------------------------------------| +| [`polyfill-php54`] | `PHPCompatibilitySymfonyPolyfillPHP54` | | +| [`polyfill-php55`] | `PHPCompatibilitySymfonyPolyfillPHP55` | [`PHPCompatibilityPasswordCompat`][PHPCompatibilityPasswordCompat] | +| [`polyfill-php56`] | `PHPCompatibilitySymfonyPolyfillPHP56` | | +| [`polyfill-php70`] | `PHPCompatibilitySymfonyPolyfillPHP70` | [`PHPCompatibilityParagonieRandomCompat`][PHPCompatibilityParagonie] | +| [`polyfill-php71`] | `PHPCompatibilitySymfonyPolyfillPHP71` | | +| [`polyfill-php72`] | `PHPCompatibilitySymfonyPolyfillPHP72` | | +| [`polyfill-php73`] | `PHPCompatibilitySymfonyPolyfillPHP73` | | +| [`polyfill-php74`] | `PHPCompatibilitySymfonyPolyfillPHP74` | | +| [`polyfill-php80`] | `PHPCompatibilitySymfonyPolyfillPHP80` | | + +> [!NOTE] > About "Includes": > Some polyfills have other polyfills as dependencies. If the PHPCompatibility project offers a dedicated ruleset for the polyfill dependency, that ruleset will be included in the ruleset for the higher level polyfill. > @@ -35,32 +36,35 @@ These rulesets prevent false positives from the [PHPCompatibility standard](http > In practice, this means that if your project uses several polyfills, you can use the information in "Includes" to help you decide which rulesets to use. -## Requirements +## Funding + +**This project needs funding.** + +The project team has spend thousands of hours creating and maintaining the PHPCompatibility packages. This is unsustainable without funding. -* [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer). - - PHP 5.3+ for use with [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) 2.3.0+. - - PHP 5.4+ for use with [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) 3.0.2+. +If you use PHPCompatibility, please fund this work by setting up a monthly contribution to the [PHP_CodeSniffer Open Collective]. + +## Requirements + +* PHP > 5.4 +* [PHP_CodeSniffer] >= 3.13.3. Use the latest stable release of PHP_CodeSniffer for the best results. - The minimum _recommended_ version of PHP_CodeSniffer is version 2.6.0. -* [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) 9.0.0+. -* [PHPCompatibilityParagonie](https://github.com/PHPCompatibility/PHPCompatibilityParagonie) 1.0.0+. -* [PHPCompatibilityPasswordCompat](https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat) 1.0.0+. +* [PHPCompatibility] 10.0.0+. +* [PHPCompatibilityParagonie] 2.0.0+. +* [PHPCompatibilityPasswordCompat] 2.0.0+. ## Installation instructions -The only supported installation method is via [Composer](https://getcomposer.org/). +The only supported installation method is via [Composer]. -If you don't have a Composer plugin installed to manage the `installed_paths` setting for PHP_CodeSniffer, run the following from the command-line: -```bash -composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true -composer require --dev dealerdirect/phpcodesniffer-composer-installer:"^0.7" phpcompatibility/phpcompatibility-symfony:"*" -``` +[Composer] will automatically install the project dependencies and register the external rulesets with PHP_CodeSniffer using the [Composer PHPCS plugin]. -If you already have a Composer PHP_CodeSniffer plugin installed, run: +Run the following from the root of your project: ```bash -composer require --dev phpcompatibility/phpcompatibility-symfony:"*" +composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true +composer require --dev phpcompatibility/phpcompatibility-symfony:"^2.0@dev" ``` Next, run: @@ -70,22 +74,32 @@ vendor/bin/phpcs -i If all went well, you will now see that the PHPCompatibility and a range of PHPCompatibilitySymfony and other PHPCompatibility standards are installed for PHP_CodeSniffer. +## Upgrade instructions + +To upgrade this package, run the following command: +```bash +composer update --dev phpcompatibility/phpcompatibility-symfony --with-dependencies +``` + +> [!TIP] +> If you have a _root_ requirement in your project for one of the packages used by this project, you may need to update with `--with-all-dependencies` instead. + ## How to use -Now you can use the following commands to inspect the code in your project for PHP cross-version compatibility: +You can now use the following commands to inspect the code in your project for PHP cross-version compatibility: ```bash -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP54 -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP55 -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP56 -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP70 -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP71 -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP72 -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP73 -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP74 -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP80 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP54 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP55 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP56 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP70 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP71 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP72 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP73 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP74 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP80 # You can also combine the standards if your project uses several: -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP55,PHPCompatibilitySymfonyPolyfillPHP70,PHPCompatibilitySymfonyPolyfillPHP73 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP55,PHPCompatibilitySymfonyPolyfillPHP70,PHPCompatibilitySymfonyPolyfillPHP73 ``` By default, you will only receive notifications about deprecated and/or removed PHP features. @@ -95,20 +109,20 @@ To get the most out of the PHPCompatibilitySymfony rulesets, you should specify For example: ```bash # For a project which should be compatible with PHP 5.3 up to and including PHP 7.0: -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP56 --runtime-set testVersion 5.3-7.0 +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP56 --runtime-set testVersion 5.3-7.0 # For a project which should be compatible with PHP 7.2 and higher: -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP73 --runtime-set testVersion 7.2- +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP73 --runtime-set testVersion 7.2- ``` -For more detailed information about setting the `testVersion`, see the README of the generic [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions) standard. +For more detailed information about setting the `testVersion`, see the README of the generic [PHPCompatibility]([PHPCompatibility-testVersion] standard. ### Testing PHP files only -By default PHP_CodeSniffer will analyse PHP, JavaScript and CSS files. As the PHPCompatibility sniffs only target PHP code, you can make the run slightly faster by telling PHP_CodeSniffer to only check PHP files, like so: +By default PHP_CodeSniffer < 4.0 will analyse PHP, JavaScript and CSS files. As the PHPCompatibility sniffs only target PHP code, you can make the run slightly faster by telling PHP_CodeSniffer to only check PHP files, like so: ```bash -./vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP71 --extensions=php --runtime-set testVersion 5.3- +vendor/bin/phpcs -p . --standard=PHPCompatibilitySymfonyPolyfillPHP71 --extensions=php --runtime-set testVersion 5.3- ``` ## License @@ -116,15 +130,23 @@ By default PHP_CodeSniffer will analyse PHP, JavaScript and CSS files. As the PH All code within the PHPCompatibility organisation is released under the GNU Lesser General Public License (LGPL). For more information, visit . -[`PHPCompatibilityPasswordCompat`]: https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat -[`PHPCompatibilityParagonieRandomCompat`]: https://github.com/PHPCompatibility/PHPCompatibilityParagonie - -[`polyfill-php54`]: https://github.com/symfony/polyfill-php54 -[`polyfill-php55`]: https://github.com/symfony/polyfill-php55 -[`polyfill-php56`]: https://github.com/symfony/polyfill-php56 -[`polyfill-php70`]: https://github.com/symfony/polyfill-php70 -[`polyfill-php71`]: https://github.com/symfony/polyfill-php71 -[`polyfill-php72`]: https://github.com/symfony/polyfill-php72 -[`polyfill-php73`]: https://github.com/symfony/polyfill-php73 -[`polyfill-php74`]: https://github.com/symfony/polyfill-php74 -[`polyfill-php80`]: https://github.com/symfony/polyfill-php80 +[packagist]: https://packagist.org/packages/phpcompatibility/phpcompatibility-symfony +[Composer]: https://getcomposer.org/ +[Composer PHPCS plugin]: https://github.com/PHPCSStandards/composer-installer/ +[PHP_CodeSniffer]: https://github.com/PHPCSStandards/PHP_CodeSniffer +[PHP_CodeSniffer Open Collective]: https://opencollective.com/php_codesniffer +[PHPCompatibility]: https://github.com/PHPCompatibility/PHPCompatibility +[PHPCompatibility-testVersion]: https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions +[PHPCompatibilityParagonie]: https://github.com/PHPCompatibility/PHPCompatibilityParagonie +[PHPCompatibilityPasswordCompat]: https://github.com/PHPCompatibility/PHPCompatibilityPasswordCompat + +[Symfony polyfill libraries]: https://github.com/symfony?utf8=?&q=polyfill +[`polyfill-php54`]: https://github.com/symfony/polyfill-php54 +[`polyfill-php55`]: https://github.com/symfony/polyfill-php55 +[`polyfill-php56`]: https://github.com/symfony/polyfill-php56 +[`polyfill-php70`]: https://github.com/symfony/polyfill-php70 +[`polyfill-php71`]: https://github.com/symfony/polyfill-php71 +[`polyfill-php72`]: https://github.com/symfony/polyfill-php72 +[`polyfill-php73`]: https://github.com/symfony/polyfill-php73 +[`polyfill-php74`]: https://github.com/symfony/polyfill-php74 +[`polyfill-php80`]: https://github.com/symfony/polyfill-php80 diff --git a/composer.json b/composer.json index e748690..48f83a3 100644 --- a/composer.json +++ b/composer.json @@ -25,12 +25,11 @@ "lock": false }, "require" : { - "phpcompatibility/php-compatibility" : "^9.0", - "phpcompatibility/phpcompatibility-paragonie" : "^1.0", - "phpcompatibility/phpcompatibility-passwordcompat" : "^1.0" + "phpcompatibility/php-compatibility" : "^10.0@dev", + "phpcompatibility/phpcompatibility-paragonie" : "^2.0@dev", + "phpcompatibility/phpcompatibility-passwordcompat" : "^2.0@dev" }, "require-dev" : { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", "symfony/polyfill-php54": "1.19", "symfony/polyfill-php55": "1.19", "symfony/polyfill-php56": "1.19", @@ -41,9 +40,5 @@ "symfony/polyfill-php74": "1.x-dev", "symfony/polyfill-php80": "1.x-dev" }, - "suggest" : { - "dealerdirect/phpcodesniffer-composer-installer": "^1.0 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." - }, "prefer-stable" : true }