Skip to content

Commit

Permalink
Base rules
Browse files Browse the repository at this point in the history
  • Loading branch information
pekral committed Jan 9, 2023
1 parent 8ffb662 commit 631e53c
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.idea
/vendor
.DS_Store
tests/.DS_Store
.phpunit.result.cache
/.phpunit.result.cache
composer.lock
16 changes: 16 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "pekral/phpcs-rules",
"description": "PHPCS - custom rule set",
"license": ["MIT"],
"require": {
"php": "^8.1",
"slevomat/coding-standard": "^8.8"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
205 changes: 205 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
<?xml version="1.0"?>
<ruleset name="Pekral - PHPCS custom rules">
<!-- Base PHPCS configuration -->
<config name="installed_paths" value="../../slevomat/coding-standard"/>
<arg name="extensions" value="php" />
<arg name="encoding" value="utf-8" />
<arg name="colors"/>
<arg name="tab-width" value="4"/>

<!-- Enabled rules with configuration-->
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="caseSensitive" value="false"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" value="0"/>
<property name="newlinesCountAfterDeclare" value="2"/>
<property name="spacesCountAroundEqualsSign" value="1"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="false"/>
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<property name="enableObjectTypeHint" value="false"/>
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEmpty"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators"/>
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<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.ForbiddenClasses"/>
<rule ref="SlevomatCodingStandard.PHP.RequireNowdoc"/>
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing"/>
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/>
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/>
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration"/>
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
<properties>
<property name="linesCountBetweenUseTypes" value="1"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Numbers.DisallowNumericLiteralSeparator"/>
<rule ref="SlevomatCodingStandard.PHP.ReferenceSpacing"/>
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax"/>
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<rule ref="SlevomatCodingStandard.PHP.ShortList"/>
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces"/>
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility"/>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<rule ref="SlevomatCodingStandard.Classes.BackedEnumTypeSpacing"/>
<rule ref="SlevomatCodingStandard.Complexity.Cognitive">
<properties>
<property name="maxComplexity" value="10"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Files.FileLength">
<properties>
<property name="maxLinesLength" value="1000"/>
</properties>
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ClassLength">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces"/>
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<rule ref="SlevomatCodingStandard.Commenting.DisallowCommentAfterCode"/>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations"/>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments"/>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing"/>
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment"/>
<rule ref="SlevomatCodingStandard.Commenting.UselessFunctionDocComment"/>
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountAfterControlStructure"/>
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineTernaryOperator">
<properties>
<property name="lineLengthLimit" value="120"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature">
<properties>
<property name="maxLineLength" value="189"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/>
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall">
<properties>
<property name="minLineLength" value="190"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall">
<properties>
<property name="maxLineLength" value="189"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition">
<properties>
<property name="minLineLength" value="170"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousErrorNaming"/>
<rule ref="SlevomatCodingStandard.Classes.ForbiddenPublicProperty"/>

<!-- PHP 8 -->
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse"/>
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat"/>
<rule ref="SlevomatCodingStandard.Functions.FunctionLength">
<properties>
<property name="maxLinesLength" value="50"/>
</properties>
<exclude-pattern>tests/*</exclude-pattern>
</rule>

<!-- Enable after refactoring -->
<exclude name="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
</ruleset>

0 comments on commit 631e53c

Please sign in to comment.