From 19fb4e272729ccbbe2708bf302923ef6bb3335c0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 23 Nov 2025 05:09:18 +0100 Subject: [PATCH] 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 @@ - - - - - - - - +