prestashop-plugin/phpcs.xml.dist
2023-07-14 13:24:01 +02:00

356 lines
15 KiB
XML

<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="parallel" value="1"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<description>The coding standard for the PrestaShop BTCPay Server module</description>
<!-- Check the following folders -->
<file>modules/btcpay/</file>
<!-- Ignore the vendor folder -->
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Import PSR-2 coding standard (base) -->
<rule ref="PSR2">
<!-- We currently don't enforce line length limits -->
<exclude name="Generic.Files.LineLength"/>
<!-- Disable no tabs allowed -->
<exclude name="Generic.WhiteSpace.DisallowTabIndent"/>
<!-- Namespaces can be missing, because this is Prestashop -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
</rule>
<!-- Forbid `array(...)` -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Forbid duplicate classes -->
<rule ref="Generic.Classes.DuplicateClassName"/>
<!-- Forbid empty statements -->
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<!-- Allow a catch statement with only comments -->
<rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedCatch">
<severity>0</severity>
</rule>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<!-- Forbid final methods in final classes -->
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<!-- Forbid inline HTML in PHP code -->
<rule ref="Generic.Files.InlineHTML"/>
<rule ref="Generic.Files.OneClassPerFile"/>
<rule ref="Generic.Files.OneInterfacePerFile"/>
<!-- Force whitespace after a type cast -->
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<rule ref="Generic.Functions.CallTimePassByReference"/>
<rule ref="Generic.Metrics.NestingLevel"/>
<!-- Forbid PHP 4 constructors -->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Forbid backtick operator -->
<rule ref="Generic.PHP.BacktickOperator"/>
<!-- Forbid any content before opening tag -->
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
<!-- Forbid deprecated functions -->
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<!-- Forbid `php_sapi_name()` function -->
<rule ref="Generic.PHP.SAPIUsage"/>
<!-- Forbid useless inline string concatenation -->
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<!-- But multiline is useful for readability -->
<properties>
<property name="allowMultiline" value="true"/>
</properties>
</rule>
<!-- Force tabs to be used -->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
<!-- Forbid comments starting with # -->
<rule ref="PEAR.Commenting.InlineComment"/>
<rule ref="PEAR.Files.IncludingFile"/>
<!-- Disallow else if in favor of elseif -->
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
<type>error</type>
</rule>
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<!-- Require comma after last element in multi-line array -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition"/>
<!-- Forbid empty lines around type declarations -->
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>
<!-- Enforce doc comment spacing -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
<!-- Except lines between description and annotations -->
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectLinesCountBetweenDescriptionAndAnnotations"/>
<!-- Except lines between annotations and other annotations -->
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectLinesCountBetweenDifferentAnnotationsTypes"/>
<properties>
<property name="linesCountAfterLastContent" value="0"/>
<property name="linesCountBeforeFirstContent" value="0"/>
</properties>
</rule>
<!-- Forbid empty comments -->
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
<properties>
<property name="forbiddenAnnotations" type="array" value="@api,@author,@category,@created,@license,@package,@since,@subpackage,@version"/>
</properties>
</rule>
<!-- Forbid useless comments -->
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
<properties>
<property name="forbiddenCommentPatterns" type="array" value="~^Created by \S+\.\z~i,~^\S+ [gs]etter\.\z~i,~(\S+\s+)?constructor\.~"/>
</properties>
</rule>
<!-- report invalid format of inline phpDocs with @var -->
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<!-- Disallows `continue` without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing"/>
<!-- Require language constructs without parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<!-- Require new instances with parentheses -->
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<!-- Requires use of null coalesce equal operator when possible. -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
<!-- Require usage of null coalesce operator when possible -->
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<!-- Forbid useless unreachable catch blocks -->
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue"/>
<!-- Require use statements to be alphabetically sorted -->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- Forbid fancy group uses -->
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/>
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<properties>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<!-- Forbid superfluous leading backslash in use statements -->
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<!-- Forbid useless uses of the same namespace -->
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall"/>
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
<!-- Enforces shorthand cast operators, forbids use of unset and binary cast operators -->
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
<!-- Require space around colon in return types -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!-- Forbid spaces around square brackets -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<!-- Force array declaration structure -->
<rule ref="Squiz.Arrays.ArrayDeclaration">
<!-- Allow the final ] to be on the same line in a multi-line array -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine"/>
<!-- Disable alignment of braces -->
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
<!-- Allow values to not be on a newline -->
<exclude name="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline"/>
<!-- Uses indentation of only single space -->
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
<!-- Allow multi-line arrays with just one value -->
<exclude name="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed"/>
<!-- This is checked by SlevomatCodingStandard.Arrays.TrailingArrayComma -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
<!-- Allow array values without a key value -->
<exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
<!-- Allow multiple values on a single line -->
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
<!-- Allow values to not be on a newline -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline"/>
<!-- Disable alignment of values with opening brace -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
</rule>
<!-- Forbid duplicate properties -->
<rule ref="Squiz.Classes.DuplicateProperty"/>
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
<rule ref="Squiz.Classes.SelfMemberReference"/>
<!-- Force phpDoc alignment -->
<rule ref="Squiz.Commenting.DocCommentAlignment">
<!-- Allow extra spaces after star, i.e. for indented annotations -->
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
</rule>
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1"/>
</properties>
</rule>
<!-- Forbid global functions -->
<rule ref="Squiz.Functions.GlobalFunction"/>
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
<!-- Forbid `global` -->
<rule ref="Squiz.PHP.GlobalKeyword"/>
<!-- Forbid functions inside functions -->
<rule ref="Squiz.PHP.InnerFunctions"/>
<!-- Require PHP function calls in lowercase -->
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
<!-- Forbid dead code -->
<rule ref="Squiz.PHP.NonExecutableCode"/>
<!-- Forbid `$this` inside static function -->
<rule ref="Squiz.Scope.StaticThisUsage"/>
<!-- Force whitespace before and after concatenation -->
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
<property name="spacing" value="1"/>
</properties>
</rule>
<!-- Forbid braces around string in `echo` -->
<rule ref="Squiz.Strings.EchoedStrings"/>
<!-- Forbid spaces in type casts -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbid blank line after function opening brace -->
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
<!-- Require space after language constructs -->
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
<!-- Require space around logical operators -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbid spaces around `->` operator -->
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid multiple spaces after operators like '=' -->
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Forbid superfluous whitespaces -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- turned on by PSR2 -> turning back off -->
<property name="ignoreBlankLines" value="false"/>
</properties>
</rule>
</ruleset>