Skip to content

Commit

Permalink
Added phpcs config file, useful for moodle-plugin-ci own style
Browse files Browse the repository at this point in the history
Note that this is the config that I was using here since ages
ago and it aligns 99% with the moodle-cs one.

Basically, it's PSR12 with a few customisations.
  • Loading branch information
stronk7 committed Apr 10, 2024
1 parent 1d3cc61 commit 6030ecd
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset>
<description>The coding rules configuration for the moodle-plugin-ci project.</description>

<!-- By default, we want to check the src and tests directories -->
<file>./src</file>
<file>./tests</file>

<!-- We don't want to analyse these -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/moodle/*</exclude-pattern>
<exclude-pattern>*/tests/Fixture/*</exclude-pattern>
<exclude-pattern>*/tests/*/Fixture/*</exclude-pattern>

<!-- PSR12 with a few exceptions and adjustments -->
<rule ref="PSR12">
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine"/>
</rule>

<!-- Some more chars don't hurt too much -->
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="132"/>
<property name="absoluteLineLimit" value="180"/>
</properties>
</rule>

<!-- We want to enforce && and || instead of and and or -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>

<!-- We want to use always the short array syntax -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

<!-- We want better commas managing -->
<!-- Space after comma -->
<rule ref="moodle.WhiteSpace.SpaceAfterComma"/>
<!-- Comma at the end of multi-line arrays -->
<rule ref="NormalizedArrays.Arrays.CommaAfterLast">
<exclude name="NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLineCloserSameLine" />
</rule>

<!--PHPCompatibility configuration-->
<rule ref="./vendor/phpcompatibility/php-compatibility/PHPCompatibility/ruleset.xml"/>
<config name="testVersion" value="8.1-"/>
</ruleset>

0 comments on commit 6030ecd

Please sign in to comment.