Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The Drupal.Arrays.Array rule currently has a hard line limit on 80 characters without any option to override this limit. It would be nice to have an option like the one available on the Drupal.Files.LineLength rule. This rule allows the line limit to be set via a phpcs:set:
phpcs:set Drupal.Files.LineLength lineLimit 100
or via a ruleset.xml
<rule ref="Drupal.Files.LineLength">
<properties>
<property name="lineLimit" value="100"/>
</properties>
</rule>
Proposed resolution
Add a lineLimit property to the Drupal.Arrays.Array rule, defaulting to 80 characters, allowing a user to override the settings using php:set:
phpcs:set Drupal.Arrays.Array lineLimit 100
or via a ruleset.xml
<rule ref="Drupal.Arrays.Array">
<properties>
<property name="lineLimit" value="100"/>
</properties>
</rule>
Comments
Comment #2
Arkener CreditAttribution: Arkener at INDICIA commentedPR: https://github.com/pfrenssen/coder/pull/71
Comment #3
klausiThe coding standards explicitly say you must use 80 characters at https://www.drupal.org/docs/develop/standards/coding-standards#array
Despite that I think the config option does not hurt and we can accept this feature request. Thanks for your PR, it mostly looks good. Left some minor comments there.
Comment #4
Arkener CreditAttribution: Arkener at INDICIA commentedI've updated the PR with fixes for the given feedback.
Comment #6
klausiMerged!
Thanks a lot Arkener, you are on fire! Keep those Coder contributions coming and let me know if you need any help :-)