coding-standards-php icon indicating copy to clipboard operation
coding-standards-php copied to clipboard

RCAT-759: Setting PHP version shouldn't be done in base rulesets

Open b-sharpe opened this issue 6 months ago • 2 comments

Describe the bug Since #76 phpcompatibility now loads top-down versions of php using the last one as it's ruleset. Since this change and the set version in the main ruleset (see #37 ) it is now impossible to set a php version outside of that if using the ruleset.

To Reproduce Set your testVersion to anything other than 7.4- in your phpcs.xml (I was using 8.3), and then run a phpcs with a rule like would break in 7.4 or below, you will see it break, i.e.

--------------------------------------------------------------------------------
 37 | ERROR | Trailing commas are not allowed in function declaration parameter
    |       | lists in PHP 7.4 or earlier
    |       | (PHPCompatibility.FunctionDeclarations.NewTrailingComma.InParameterList)
--------------------------------------------------------------------------------

Expected behavior PHPCompatibility should use the set php version in phpcs.xml

Proposed Fix Remove the set testversion in src/Standards/AcquiaDrupalMinimal/ruleset.xml and instead set this in example/phpcs.xml.dist so that the user is in control of the testVersion

b-sharpe avatar Jul 29 '25 17:07 b-sharpe

I was facing the same issue, and the patch fixed it. Thanks!

halisonfernandes avatar Aug 27 '25 14:08 halisonfernandes

This patch fixed it for me. Thx!

andrebonon avatar Nov 10 '25 14:11 andrebonon