Skip to content

Instantly share code, notes, and snippets.

@kiler129
Created December 4, 2022 23:11
Show Gist options
  • Save kiler129/697d70c7a6430350c5234ec01194528c to your computer and use it in GitHub Desktop.
Save kiler129/697d70c7a6430350c5234ec01194528c to your computer and use it in GitHub Desktop.
<?xml version="1.0"?>
<ruleset name="Lab Companion" namespace="NoFlash\LabCompanion\CS\Standard">
<config name="installed_paths" value="../../slevomat/coding-standard"/>
<ini name="memory_limit" value="512M"/>
<arg name="colors"/>
<arg name="basepath" value="."/>
<arg name="parallel" value="8" />
<autoload>./vendor/autoload.php</autoload>
<file>src</file>
<file>tests</file>
<!-- Don't hide tokenizer exceptions -->
<rule ref="Internal.Tokenizer.Exception">
<type>error</type>
</rule>
<rule ref="PSR2"/>
<!-- ############################################################################ -->
<!-- PHPCS built-in rules -->
<!-- ############################################################################ -->
<rule ref="Generic.Files.LineLength.TooLong" />
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<!-- Use proper logging facilities -->
<element key="echo" value="null"/>
<element key="print" value="null"/>
<element key="is_null" value="null"/> <!-- Use "$x === null" instead -->
<element key="die" value="null"/> <!-- Replace by proper code return or exception -->
<element key="create_function" value="null"/> <!-- Deprecated, use lambdas -->
<element key="eval" value="null"/> <!-- Does this need a comment? -->
<element key="goto" value="null"/> <!-- https://xkcd.com/292/ -->
<element key="define" value="null"/> <!-- Use const keyword -->
<!-- Use proper syntax -->
<element key="extract" value="null"/>
<element key="call_user_func" value="null"/>
<element key="call_user_func_array" value="null"/>
</property>
</properties>
</rule>
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="15" />
<property name="absoluteComplexity" value="15" />
</properties>
</rule>
<rule ref="Generic.Metrics.NestingLevel" />
<!-- ############################################################################ -->
<!-- Sourced from https://github.com/slevomat/coding-standard -->
<!-- ############################################################################ -->
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/arrays.md -->
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation" />
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement" />
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace" />
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/attributes.md -->
<rule ref="SlevomatCodingStandard.Attributes.RequireAttributeAfterDocComment" />
<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0" />
<property name="spacesCountBeforeType" value="1" />
</properties>
</rule>
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/classes.md -->
<rule ref="SlevomatCodingStandard.Classes.ClassLength">
<exclude-pattern>src/DataFixtures/GeneratorProvider/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing">
<properties>
<property name="linesCountBetweenMembers" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing">
<properties>
<property name="linesCountBetweenMembers" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing">
<properties>
<property name="minLinesCountBeforeWithComment" value="1" />
<property name="maxLinesCountBeforeWithComment" value="2" />
<property name="minLinesCountBeforeWithoutComment" value="0" />
<property name="maxLinesCountBeforeWithoutComment" value="2" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants" />
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition" /> <!-- this makes a hot mess in git -->
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition" /> <!-- this makes a hot mess in git -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0" />
<property name="linesCountBeforeClosingBrace" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing">
<properties>
<property name="minLinesCount" value="1" />
<property name="maxLinesCount" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference" />
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration">
<properties>
<property name="checkPromoted" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing">
<properties>
<property name="minLinesCountBeforeWithComment" value="1" />
<property name="maxLinesCountBeforeWithComment" value="2" />
<property name="minLinesCountBeforeWithoutComment" value="0" />
<property name="maxLinesCountBeforeWithoutComment" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion" />
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature">
<properties>
<!-- I know PSR, we have wide screens ffs - 120 is STILL within the limits of the standard -->
<property name="minLineLength" value="120" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature">
<properties>
<property name="maxLineLength" value="80" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration" /> <!-- this makes a hot mess in git -->
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<properties>
<property name="linesCountBeforeFirstUse" value="0" />
<property name="linesCountBeforeFirstUseWhenFirstInClass" value="0" />
<property name="linesCountBetweenUses" value="0" />
<property name="linesCountAfterLastUse" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/commenting.md -->
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration" />
<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" />
<element value="@throws" />
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property ref="forbiddenCommentPatterns" type="array">
<element value="/^Constructor/i" />
<element value="/^Created by /i" />
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment" />
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration">
<properties>
<property name="allowDocCommentAboveReturn" value="true" />
<property name="allowAboveNonAssignment" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment" />
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/complexity.md -->
<rule ref="SlevomatCodingStandard.Complexity.Cognitive" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/control-structures.md -->
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition" />
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit">
<properties>
<property name="ignoreStandaloneIfInScope" value="true" />
<property name="ignoreOneLineTrailingIf" value="true" />
<property name="ignoreTrailingIfWithOneInstruction" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch" />
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEmpty" /> <!-- No reason to sue in PHP8 -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses" />
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses" />
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator" />
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" />
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/exceptions.md -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" />
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/files.md -->
<rule ref="SlevomatCodingStandard.Files.FileLength">
<exclude-pattern>src/DataFixtures/GeneratorProvider/</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Files.LineLength">
<properties>
<property name="lineLengthLimit" value="120" />
<property name="ignoreComments" value="true" />
<property name="ignoreImports" value="true" />
</properties>
</rule>
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/functions.md -->
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
<properties>
<property ref="spacesCountAfterKeyword" value="1" />
<property ref="spacesCountBeforeArrow" value="1" />
<property ref="spacesCountAfterArrow" value="1" />
<property ref="allowMultiLine" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction" />
<rule ref="SlevomatCodingStandard.Functions.FunctionLength">
</rule>
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction">
<properties>
<property name="allowNested" value="false" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInCall" />
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse" />
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration" />
<rule ref="SlevomatCodingStandard.Functions.StaticClosure" />
<rule ref="SlevomatCodingStandard.Functions.StrictCall" />
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
<rule ref="SlevomatCodingStandard.Functions.UnusedParameter" />
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="psr12Compatible" value="true" />
<property name="caseSensitive" value="false" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" />
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants" />
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions" />
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine" />
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration" />
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing">
<properties>
<property name="linesCountBeforeNamespace" value="1" />
<property name="linesCountAfterNamespace" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile" />
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="searchAnnotations" value="true" />
<property name="allowFullyQualifiedNameForCollidingClasses" value="true" />
<property name="allowFullyQualifiedNameForCollidingFunctions" value="true" />
<property name="allowFullyQualifiedNameForCollidingConstants" value="true" />
<property name="allowFullyQualifiedGlobalClasses" value="true" />
<property name="allowFullyQualifiedGlobalFunctions" value="true" />
<property name="allowFullyQualifiedGlobalConstants" value="true" />
<property name="allowFallbackGlobalFunctions" value="true" />
<property name="allowFallbackGlobalConstants" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace" />
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountBeforeFirstUse" value="1" />
<property name="linesCountAfterLastUse" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias" />
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true" />
</properties>
</rule>
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/numbers.md -->
<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator">
<properties>
<property name="minDigitsBeforeDecimalPoint" value="5" />
<property name="ignoreOctalNumbers" value="true" />
</properties>
</rule>
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/operators.md -->
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators" />
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing">
<properties>
<property name="spacesCount" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator" />
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing">
<properties>
<property name="spacesCountAfterOperator" value="0" />
</properties>
</rule>
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/php.md -->
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall" /> <!-- no magic methods should be called directly... -->
<rule ref="SlevomatCodingStandard.PHP.DisallowReference" /> <!-- objects should be used instead when such behavior is desired -->
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" />
<rule ref="SlevomatCodingStandard.PHP.ShortList" />
<rule ref="SlevomatCodingStandard.PHP.TypeCast" />
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses" />
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/type-hints.md -->
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="linesCountBeforeDeclare" value="0" />
<property name="spacesCountAroundEqualsSign" value="0" />
<property name="linesCountAfterDeclare" value="1" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax">
<properties>
<property name="traversableTypeHints" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint" />
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints" />
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition" />
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<property name="enableObjectTypeHint" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing" />
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableObjectTypeHint" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
<properties>
<property name="spacesCountBeforeColon" value="0" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat" />
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" />
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/variables.md -->
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable" />
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable" />
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable">
<properties>
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" />
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable">
<properties>
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" />
</properties>
</rule>
<!-- Docs: https://github.com/slevomat/coding-standard/blob/master/doc/whitespaces.md -->
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces">
<properties>
<property name="ignoreSpacesBeforeAssignment" value="true" />
<property name="ignoreSpacesInAnnotation" value="true" />
<property name="ignoreSpacesInComment" value="true" />
<property name="ignoreSpacesInParameters" value="true" />
<property name="ignoreSpacesInMatch" value="true" />
</properties>
</rule>
</ruleset>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment