From 051b81791f937c4efc1045567b06b52025a2306f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 23 Nov 2025 04:34:20 +0100 Subject: [PATCH 1/7] CS: start using PHPCompatibility 10 Long anticipated, finally here: PHPCompatibility 10.0.0-alpha1 :tada: PHPCompatibility 10.0.0 brings huge improvements in both what is being detected (> 50 new sniffs), as well as the detection accuracy for pre-existing sniffs. Even though still "unstable", it is stable enough for our purposes and the advantages of using it outweigh the disadvantage of it being an unstable version. By setting the `minimum-stability` and `prefer-stable` settings in the `composer.json`, we can ensure that we don't get the `dev-develop` branch, but rather get a `10.0.0` tag, unstable or not. Includes updating the PHPCS version constraints to match. Includes updating the exclusions in the ruleset for changes in the error codes due to further changes in PHP having been made (and now being detected). Ref: * https://github.com/PHPCompatibility/PHPCompatibility/wiki/Upgrading-to-PHPCompatibility-10.0 * https://github.com/PHPCompatibility/PHPCompatibility/releases/tag/10.0.0-alpha1 --- composer.json | 6 ++++-- phpcs.xml.dist | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 05b05c75..6af16647 100644 --- a/composer.json +++ b/composer.json @@ -42,8 +42,8 @@ "doctrine/annotations": "^1.2.6 || ^1.13.3", "php-parallel-lint/php-console-highlighter": "^1.0.0", "php-parallel-lint/php-parallel-lint": "^1.3.2", - "phpcompatibility/php-compatibility": "^9.3.5", - "squizlabs/php_codesniffer": "^3.7.2", + "phpcompatibility/php-compatibility": "^10.0.0@dev", + "squizlabs/php_codesniffer": "^3.13.5", "yoast/phpunit-polyfills": "^1.0.4" }, "suggest": { @@ -58,6 +58,8 @@ "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)", "thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication" }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { "PHPMailer\\PHPMailer\\": "src/" diff --git a/phpcs.xml.dist b/phpcs.xml.dist index e2d1e5c6..5642fd91 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -30,9 +30,9 @@ - + - + From 19fb4e272729ccbbe2708bf302923ef6bb3335c0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 23 Nov 2025 05:09:18 +0100 Subject: [PATCH 2/7] PHPCS/PHPCompatibility: favour inline ignores over blanket rule excludes Best practice tweak regarding the use of PHPCompatibility. It is strongly recommended to use inline ignore annotations when a reported issue is not a problem (because it is accompanied by a `function_exists()`, `defined()` or other check), instead of excluding a rule completely via the ruleset. Blanket code-base wide ignores mean that: * ... if a PR introduces new code (or changes existing code) which uses a non-cross-version compatible PHP feature... * ... and the code doesn't have the right safeguards in place for cross-version compatibility... * ... PHPCompatibility would not flag it because of the codebase wide ignore... * ... which could cause problems for the end-users. Selective, inline ignores ensure that only the annotated error is ignored and only for that specific bit of code, preventing the above described problem. It also means that when something changes in PHP - like a deprecated method being removed -, you will be notified about the issue again so you can review if the current cross-version compatibility tweak is still the most optimal one. --- phpcs.xml.dist | 9 +-------- src/PHPMailer.php | 4 ++++ src/SMTP.php | 2 ++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 5642fd91..bf51a72c 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -27,14 +27,7 @@ - - - - - - - - +