winter/phpcs.xml
2022-07-06 15:00:34 -06:00

139 lines
7.8 KiB
XML

<?xml version="1.0"?>
<ruleset name="Winter CMS">
<description>The coding standard for Winter CMS.</description>
<rule ref="PSR2">
<!--
Exceptions to the PSR-2 guidelines as per our Developer Guide:
https://wintercms.com/help/guidelines/developer#psr-exceptions
-->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" />
<exclude name="PSR2.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace" />
<!-- We're not enforcing a line length limit -->
<exclude name="Generic.Files.LineLength" />
</rule>
<rule ref="Squiz.ControlStructures.ControlSignature">
<!-- We use 0 spaces before the colon for short (alternative) tags -->
<properties>
<property name="requiredSpacesBeforeColon" value="0" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen">
<!--
Ignore correct spacing for control structure in partial templates - spacing may be useful for templates to
easily deduce HTML code that is conditional
-->
<exclude-pattern>*/modules/*/behaviors/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/components/*/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/controllers/*/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/formwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/reportwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/widgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/behaviors/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/components/*/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/controllers/*/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/formwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/reportwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/widgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/partials/*\.php</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<!-- Migration files and tests do not need a namespace defined -->
<exclude-pattern>*/database/migrations/*\.php</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<!--
Test fixtures and cases can have multiple classes defined, only if they are directly related to the test, or are
extended classes
-->
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="PSR2.Files.ClosingTag.NotAllowed">
<!--
Partials may finish on a closing tag, especially when using the short echo "<?= ?>" tag. We'll allow this.
-->
<exclude-pattern>*/modules/*/behaviors/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/components/*/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/controllers/*/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/formwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/reportwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/widgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/behaviors/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/components/*/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/controllers/*/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/formwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/reportwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/widgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/partials/*\.php</exclude-pattern>
</rule>
<rule ref="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLineCASE">
<!--
Partials may have HTML within switch/case statements, which look neater when inline. PHPCS also has difficulty
interpreting a short echo tag on a new line within a switch/case statement.
-->
<exclude-pattern>*/modules/*/behaviors/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/components/*/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/controllers/*/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/formwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/reportwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/widgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/behaviors/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/components/*/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/controllers/*/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/formwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/reportwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/widgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/partials/*\.php</exclude-pattern>
</rule>
<rule ref="PSR2.ControlStructures.SwitchDeclaration.BreakNotNewLine">
<!--
Partials may have HTML within switch/case statements, which look neater when inline. PHPCS also has difficulty
interpreting a short echo tag on a new line within a switch/case statement.
-->
<exclude-pattern>*/modules/*/behaviors/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/components/*/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/controllers/*/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/formwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/reportwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/widgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/modules/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/behaviors/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/components/*/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/controllers/*/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/formwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/reportwidgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/widgets/*/partials/*\.php</exclude-pattern>
<exclude-pattern>*/plugins/*/*/partials/*\.php</exclude-pattern>
</rule>
<arg name="extensions" value="php" />
<arg name="colors" />
<file>bootstrap/</file>
<file>config/</file>
<file>modules/</file>
<file>plugins/winter/demo/</file>
<file>tests/</file>
<!-- Ignore vendor files -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Ignore this view file as fixing the issues in here will break the template -->
<exclude-pattern>modules/system/views/exception.php</exclude-pattern>
<!-- Ignore this view file as PHPCS wants line 8 to have 44 spaces instead of 12, clearly insane -->
<exclude-pattern>modules/backend/widgets/mediamanager/partials/_item-icon.php</exclude-pattern>
<!-- Ignore this test case completely as it's testing a parse error -->
<exclude-pattern>tests/fixtures/plugins/testvendor/goto/Plugin.php</exclude-pattern>
</ruleset>