phpcs.xml
<?xml version="1.0"?>
<ruleset>
<!-- Add some rulesets -->
<config name="installed_paths" value="vendor/slevomat/coding-standard"/>
<!-- Directories -->
<file>database/migrations/</file>
<file>src/</file>
<file>tests/</file>
<!-- Ignore some dependency paths -->
<exclude-pattern type="relative">^/vendor/</exclude-pattern>
<exclude-pattern type="relative">^/node_modules/</exclude-pattern>
<!-- We just use PSR-12, but need to modify two rules to work with Laravel -->
<rule ref="PSR12">
<!-- <exclude name="PSR12.Classes.ClassInstantiation" /> -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
<!-- Use After Brace is currently bugged when using comments in class start -->
<exclude name="PSR12.Traits.UseDeclaration.UseAfterBrace" />
</rule>
<!-- Database files don't have a namespace. -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern type="relative">^/database/migrations/</exclude-pattern>
</rule>
<!-- Never use "else if". -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<!-- Other types -->
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" />
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" type="int" value="2" />
<property name="spacesCountAroundEqualsSign" type="int" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
<element value="uses"/>
<element value="public constants"/>
<element value="protected constants"/>
<element value="private constants"/>
<element value="public static properties, protected static properties, private static properties"/>
<element value="static constructors"/>
<element value="public static methods, protected static methods, private static methods"/>
<element value="public static abstract methods, protected static abstract methods"/>
<element value="public properties, protected properties, private properties"/>
<element value="constructor"/>
<element value="destructor"/>
<element value="public methods"/>
<element value="protected methods"/>
<element value="private methods"/>
<element value="public abstract methods, protected abstract methods"/>
<element value="magic methods"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator" />
<rule ref="SlevomatCodingStandard.Functions.StaticClosure" />
<!-- Clean code -->
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements" />
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
<rule ref="SlevomatCodingStandard.Functions.UnusedParameter" />
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses" />
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace" />
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias" />
<rule ref="SlevomatCodingStandard.PHP.RequireExplicitAssertion" />
<rule ref="SlevomatCodingStandard.PHP.RequireNowdoc" />
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable" />
<rule ref="SlevomatCodingStandard.Variables.UselessVariable" />
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" />
<!-- Formatting -->
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference" />
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses" />
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction" />
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction" />
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile" />
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />
<rule ref="SlevomatCodingStandard.PHP.ShortList" />
<rule ref="SlevomatCodingStandard.PHP.TypeCast" />
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" />
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<!-- Exclude directories -->
<include-pattern type="relative">^/app/</include-pattern>
<include-pattern type="relative">^/tests/</include-pattern>
<!-- Properties -->
<properties>
<property name="rootNamespaces" type="array">
<element key="app" value="App"/>
<element key="tests" value="Tests"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array">
<element value="author"/>
<element value="created"/>
<element value="version"/>
<element value="package"/>
<element value="copyright"/>
<element value="license"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<properties>
<property name="linesCountBeforeFirstContent" type="int" value="0" />
<property name="linesCountBetweenDescriptionAndAnnotations" type="int" value="0" />
<property name="linesCountBetweenDifferentAnnotationsTypes" type="int" value="0" />
<property name="linesCountAfterLastContent" type="int" value="0" />
</properties>
</rule>
</ruleset>