2017 © Pedro Peláez
 

library coding-standard

Everon Coding Standards

image

everon/coding-standard

Everon Coding Standards

  • Saturday, July 14, 2018
  • by oliwierptak
  • Repository
  • 1 Watchers
  • 0 Stars
  • 32 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Coding Standards

Over 200 sniffs with additional checks and code analysis (eg. detecting unreachable code, unused variables, etc)., (*1)

The rule set is located in coding-standard/Everon/ruleset.xml., (*2)

Installation

Installation with composer., (*3)

composer require everon/coding-standard --dev, (*4)

Configuration

After installation create your own rule set under <project dir>phpcs.xml., (*5)

Project's configuration example., (*6)


<ruleset name="Everon">

    <exclude-pattern>*/tests/App/*</exclude-pattern>
    <exclude-pattern>*/tests/logs/*</exclude-pattern>

    <rule ref="Everon"/>
    <rule ref="Everon.Files.TypeNameMatchesFileName">
        <properties>
            <property name="rootNamespaces" type="array"
                      value="src/App=>App,tests/App=>Tests\App"/>
            <property name="skipDirs" type="array"
                      value="tests/App/Generated"/>
            <property name="extensions" type="array"
                      value="php"/>
        </properties>
    </rule>

</ruleset>

Configuring rootNamespaces will allow for the sniffs to automatically expand and take care of FQCN., (*7)

Coding Standards Usage

The rules are installed by composer post-install command automatically. But if you need to, you can run it manually with cs-setup. Once it has been executed you can start using other coding standard commands., (*8)

  vendor/bin/cs-check    Checks and reports coding style violations
  vendor/bin/cs-fix      Fixes coding style violations automatically
  vendor/bin/cs-list     Show coding standard rules
  vendor/bin/cs-setup    Execute once to setup coding standard rules

cs-check

By default it will look for code under src directory. It can be overwritten from the command line., (*9)

vendor/bin/cs-check [<path>], (*10)

cs-fix

By default it will look for code under src directory. It can be overwritten from the command line., (*11)

vendor/bin/cs-fix [<path>], (*12)

cs-list

List available coding standard rules., (*13)

vendor/bin/cs-list, (*14)

cs-setup

Run once in order to setup the coding standard. Usually it's not needed to run it, as composer post-install does it., (*15)

vendor/bin/cs-setup, (*16)

Sniffs

The EveronCodingStandard standard contains 118 sniffs

Everon (1 sniff)
-----------------
  Everon.Files.TypeNameMatchesFileName

Generic (22 sniffs)
-------------------
  Generic.Arrays.DisallowLongArraySyntax
  Generic.CodeAnalysis.ForLoopShouldBeWhileLoop
  Generic.CodeAnalysis.ForLoopWithTestFunctionCall
  Generic.CodeAnalysis.JumbledIncrementer
  Generic.CodeAnalysis.UnconditionalIfStatement
  Generic.CodeAnalysis.UnnecessaryFinalModifier
  Generic.ControlStructures.InlineControlStructure
  Generic.Files.ByteOrderMark
  Generic.Files.LineEndings
  Generic.Files.LineLength
  Generic.Formatting.DisallowMultipleStatements
  Generic.Formatting.NoSpaceAfterCast
  Generic.Functions.FunctionCallArgumentSpacing
  Generic.NamingConventions.UpperCaseConstantName
  Generic.PHP.DeprecatedFunctions
  Generic.PHP.DisallowShortOpenTag
  Generic.PHP.ForbiddenFunctions
  Generic.PHP.LowerCaseConstant
  Generic.PHP.LowerCaseKeyword
  Generic.PHP.NoSilencedErrors
  Generic.WhiteSpace.DisallowTabIndent
  Generic.WhiteSpace.ScopeIndent

PEAR (4 sniffs)
---------------
  PEAR.Classes.ClassDeclaration
  PEAR.ControlStructures.ControlSignature
  PEAR.Functions.ValidDefaultValue
  PEAR.NamingConventions.ValidClassName

PSR1 (3 sniffs)
---------------
  PSR1.Classes.ClassDeclaration
  PSR1.Files.SideEffects
  PSR1.Methods.CamelCapsMethodName

PSR2 (12 sniffs)
----------------
  PSR2.Classes.ClassDeclaration
  PSR2.Classes.PropertyDeclaration
  PSR2.ControlStructures.ControlStructureSpacing
  PSR2.ControlStructures.ElseIfDeclaration
  PSR2.ControlStructures.SwitchDeclaration
  PSR2.Files.ClosingTag
  PSR2.Files.EndFileNewline
  PSR2.Methods.FunctionCallSignature
  PSR2.Methods.FunctionClosingBrace
  PSR2.Methods.MethodDeclaration
  PSR2.Namespaces.NamespaceDeclaration
  PSR2.Namespaces.UseDeclaration

SlevomatCodingStandard (50 sniffs)
----------------------------------
  SlevomatCodingStandard.Arrays.TrailingArrayComma
  SlevomatCodingStandard.Classes.ClassConstantVisibility
  SlevomatCodingStandard.Classes.UnusedPrivateElements
  SlevomatCodingStandard.Commenting.DisallowOneLinePropertyDocComment
  SlevomatCodingStandard.Commenting.DocCommentSpacing
  SlevomatCodingStandard.Commenting.EmptyComment
  SlevomatCodingStandard.Commenting.ForbiddenAnnotations
  SlevomatCodingStandard.Commenting.ForbiddenComments
  SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration
  SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment
  SlevomatCodingStandard.ControlStructures.AssignmentInCondition
  SlevomatCodingStandard.ControlStructures.DisallowEmpty
  SlevomatCodingStandard.ControlStructures.DisallowEqualOperators
  SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator
  SlevomatCodingStandard.ControlStructures.DisallowYodaComparison
  SlevomatCodingStandard.ControlStructures.EarlyExit
  SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses
  SlevomatCodingStandard.ControlStructures.NewWithParentheses
  SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator
  SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator
  SlevomatCodingStandard.ControlStructures.RequireYodaComparison
  SlevomatCodingStandard.Exceptions.DeadCatch
  SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly
  SlevomatCodingStandard.Files.TypeNameMatchesFileName
  SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses
  SlevomatCodingStandard.Namespaces.DisallowGroupUse
  SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword
  SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation
  SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions
  SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants
  SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions
  SlevomatCodingStandard.Namespaces.MultipleUsesPerLine
  SlevomatCodingStandard.Namespaces.NamespaceDeclaration
  SlevomatCodingStandard.Namespaces.NamespaceSpacing
  SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly
  SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile
  SlevomatCodingStandard.Namespaces.UnusedUses
  SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash
  SlevomatCodingStandard.Namespaces.UseFromSameNamespace
  SlevomatCodingStandard.Namespaces.UseSpacing
  SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators
  SlevomatCodingStandard.PHP.ShortList
  SlevomatCodingStandard.PHP.TypeCast
  SlevomatCodingStandard.TypeHints.DeclareStrictTypes
  SlevomatCodingStandard.TypeHints.LongTypeHints
  SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue
  SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing
  SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing
  SlevomatCodingStandard.TypeHints.TypeHintDeclaration
  SlevomatCodingStandard.Types.EmptyLinesAroundTypeBraces

Squiz (26 sniffs)
-----------------
  Squiz.Arrays.ArrayBracketSpacing
  Squiz.Classes.LowercaseClassKeywords
  Squiz.Classes.ValidClassName
  Squiz.Commenting.DocCommentAlignment
  Squiz.ControlStructures.ControlSignature
  Squiz.ControlStructures.ForEachLoopDeclaration
  Squiz.ControlStructures.ForLoopDeclaration
  Squiz.ControlStructures.LowercaseDeclaration
  Squiz.Functions.FunctionDeclaration
  Squiz.Functions.FunctionDeclarationArgumentSpacing
  Squiz.Functions.LowercaseFunctionKeywords
  Squiz.Functions.MultiLineFunctionDeclaration
  Squiz.Operators.ValidLogicalOperators
  Squiz.PHP.Eval
  Squiz.PHP.NonExecutableCode
  Squiz.Scope.MemberVarScope
  Squiz.Scope.MethodScope
  Squiz.Scope.StaticThisUsage
  Squiz.WhiteSpace.ControlStructureSpacing
  Squiz.WhiteSpace.LanguageConstructSpacing
  Squiz.WhiteSpace.LogicalOperatorSpacing
  Squiz.WhiteSpace.MemberVarSpacing
  Squiz.WhiteSpace.ScopeClosingBrace
  Squiz.WhiteSpace.ScopeKeywordSpacing
  Squiz.WhiteSpace.SemicolonSpacing
  Squiz.WhiteSpace.SuperfluousWhitespace

The Versions

14/07 2018

dev-master

9999999-dev

Everon Coding Standards

  Sources   Download

MIT

The Requires

 

by Oliwier Ptak

06/07 2018

1.0.3

1.0.3.0

Everon Coding Standards

  Sources   Download

MIT

The Requires

 

by Oliwier Ptak

06/07 2018

1.0.2

1.0.2.0

Everon Coding Standards

  Sources   Download

MIT

The Requires

 

by Oliwier Ptak

06/07 2018

1.0.1

1.0.1.0

Everon Coding Standards

  Sources   Download

MIT

The Requires

 

by Oliwier Ptak

06/07 2018

1.0

1.0.0.0

Everon Coding Standards

  Sources   Download

The Requires

 

by Oliwier Ptak