feat: Add Heimerdinger PHP CS rules for Laravel

- Added a new phpcs.xml.dist file with specific coding standards for Laravel development.
This commit is contained in:
Rico van Zelst
2024-06-18 13:09:26 +02:00
parent 131c7b94d6
commit 20f08944c2
2 changed files with 73 additions and 1 deletions

67
.phpcs.xml.dist Normal file
View File

@@ -0,0 +1,67 @@
<ruleset name="Heimerdinger">
<description>Heimerdinger PHP CS rules for Laravel</description>
<!-- Ignore normal Laravel files and folders -->
<exclude-pattern>*/cache/*</exclude-pattern>
<exclude-pattern>*/*.js</exclude-pattern>
<exclude-pattern>*/*.css</exclude-pattern>
<exclude-pattern>*/*.xml</exclude-pattern>
<exclude-pattern>*/*.blade.php</exclude-pattern>
<exclude-pattern>*/autoload.php</exclude-pattern>
<exclude-pattern>*/storage/*</exclude-pattern>
<exclude-pattern>*/docs/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/migrations/*</exclude-pattern>
<!-- Hard-code command-line parameters -->
<arg name="colors" />
<arg value="p" />
<!-- PSR1 2.3 Side Effects -->
<rule ref="PSR1.Files.SideEffects">
<!-- Disable side effects for index file -->
<exclude-pattern>/public/index.php</exclude-pattern>
</rule>
<!-- PSR1 3 Namespaces and classes MUST follow PSR-0. -->
<rule ref="PSR1.Classes.ClassDeclaration" />
<!-- Disable missing namespace rule for tests and database files -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>*/database/*</exclude-pattern>
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<!-- PSR1 4.1 Class constants MUST be declared in all upper case with underscore separators. -->
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />
<!-- PSR1 4.3 Method names MUST be declared in camelCase(). -->
<rule ref="PSR1.Methods.CamelCapsMethodName" />
<!-- Disable camel caps rule for tests -->
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<!-- No compact() and no 'dumps' -->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="compact" value="null" />
<element key="dd" value="null" />
<element key="dump" value="null" />
<element key="var_dump" value="null" />
<element key="ray" value="null" />
</property>
</properties>
</rule>
<!-- Use config() over env() -->
<rule ref="Tighten.PHP.UseConfigOverEnv">
<exclude-pattern>/config/*</exclude-pattern>
</rule>
<!-- Class name should match the file name -->
<rule ref="Squiz.Classes.ClassFileName" />
</ruleset>