Skip to content

Instantly share code, notes, and snippets.

@preeteshjain
Created November 14, 2019 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save preeteshjain/e694fbc2c13c888d02c4ce3f2cee2bc2 to your computer and use it in GitHub Desktop.
Save preeteshjain/e694fbc2c13c888d02c4ce3f2cee2bc2 to your computer and use it in GitHub Desktop.
My EasyCodingStandard Config
services:
# symfony style rules
PhpCsFixer\Fixer\Basic\BracesFixer:
allow_single_line_closure: true
PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer: ~
PhpCsFixer\Fixer\Operator\NewWithBracesFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer:
tags:
- method
- param
- property
- return
- throws
- type
- var
PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer: ~
PhpCsFixer\Fixer\Operator\IncrementStyleFixer: ~
PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer: ~
PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer: ~
PhpCsFixer\Fixer\CastNotation\CastSpacesFixer: ~
PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer: ~
PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer: ~
PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer:
comment_types:
- hash
PhpCsFixer\Fixer\ControlStructure\IncludeFixer: ~
PhpCsFixer\Fixer\CastNotation\LowercaseCastFixer: ~
PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer: ~
PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer: ~
PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer: ~
PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer: ~
PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer: ~
PhpCsFixer\Fixer\Semicolon\NoEmptyStatementFixer: ~
PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer:
tokens:
- curly_brace_block
- extra
- parenthesis_brace_block
- square_brace_block
- throw
- use
PhpCsFixer\Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer: ~
PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer: ~
PhpCsFixer\Fixer\CastNotation\NoShortBoolCastFixer: ~
PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer: ~
PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer: ~
PhpCsFixer\Fixer\ControlStructure\NoTrailingCommaInListCallFixer: ~
PhpCsFixer\Fixer\ArrayNotation\NoTrailingCommaInSinglelineArrayFixer: ~
PhpCsFixer\Fixer\ArrayNotation\TrailingCommaInMultilineArrayFixer: ~
PhpCsFixer\Fixer\ControlStructure\NoUnneededControlParenthesesFixer: ~
PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer: ~
PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer: ~
PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer: ~
PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocInlineTagFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocNoAccessFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocNoUselessInheritdocFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocScalarFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer: ~
PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer: ~
PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer: ~
PhpCsFixer\Fixer\CastNotation\ShortScalarCastFixer: ~
PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer: ~
PhpCsFixer\Fixer\Semicolon\SpaceAfterSemicolonFixer: ~
PhpCsFixer\Fixer\Operator\StandardizeNotEqualsFixer: ~
PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer: ~
PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer: ~
PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer: ~
PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer:
singleLine: true
PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer: ~
PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer: ~
PhpCsFixer\Fixer\Alias\NoMixedEchoPrintFixer:
use: echo
PhpCsFixer\Fixer\Import\NoLeadingImportSlashFixer: ~
PhpCsFixer\Fixer\Import\NoUnusedImportsFixer: ~
PhpCsFixer\Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer: ~
PhpCsFixer\Fixer\Phpdoc\PhpdocNoAliasTagFixer: ~
PhpCsFixer\Fixer\ClassNotation\ProtectedToPrivateFixer: ~
PhpCsFixer\Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer: ~
PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer: ~
# new since PHP-CS-Fixer 2.6
PhpCsFixer\Fixer\ControlStructure\NoUnneededCurlyBracesFixer: ~
PhpCsFixer\Fixer\ClassNotation\NoUnneededFinalMethodFixer: ~
PhpCsFixer\Fixer\Semicolon\SemicolonAfterInstructionFixer: ~
PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer: ~
# new since 2.11
PhpCsFixer\Fixer\Operator\StandardizeIncrementFixer: ~
# spaces
# $builder->addThis()\n ->addThat();
PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer: ~
# 1 empty line between constants, properties and methods
PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer:
elements: ['const', 'property', 'method']
# "string" . "another string"
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
spacing: one
# ...
PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff:
ignoreBlankLines: false
# $value = ( type ) ...;
PhpCsFixer\Fixer\CastNotation\CastSpacesFixer: ~
# $value + = 5;
PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer:
align_double_arrow: false
align_equals: false
# someMethod( string $value)
PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer: ~
# class someClass {\n\n
PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer: ~
# $value = 5 ;
PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer: ~
# /** @var Type $variable */
PhpCsFixer\Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer: ~
# namespace ...;
PhpCsFixer\Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer: ~
# $value[ 'key' ];
PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer: ~
# \n \n
PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer: ~
# someMethod() : Type
PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer: ~
# $var = 5; $hello = 'hi';
PhpCsFixer\Fixer\Semicolon\SpaceAfterSemicolonFixer: ~
# '$value ? 'yes' : 'no';
PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer: ~
# someFunction($value,$anotherValue)
PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer: ~
PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\LanguageConstructSpacingSniff: ~
SlevomatCodingStandard\Sniffs\Classes\TraitUseSpacingSniff:
linesCountAfterLastUse: 1
linesCountAfterLastUseWhenLastInClass: 0
linesCountBeforeFirstUse: 0
linesCountBetweenUses: 0
# arrays
# [ 1 , 2];
PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer: ~
# [ 1, 2 ];
PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer: ~
# [ 1,\n2 ];
PhpCsFixer\Fixer\ArrayNotation\TrailingCommaInMultilineArrayFixer: ~
# [1, ] => [1]
PhpCsFixer\Fixer\ArrayNotation\NoTrailingCommaInSinglelineArrayFixer: ~
# array( );
PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer:
syntax: short
# [1,2]
PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer: ~
PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer: ~
# namespaces
# remove unused aliases
SlevomatCodingStandard\Sniffs\Namespaces\UselessAliasSniff: ~
# drop dead use namespaces
PhpCsFixer\Fixer\Import\NoUnusedImportsFixer: ~
# and sort them A → Z
PhpCsFixer\Fixer\Import\OrderedImportsFixer: ~
# <?php\nnamespace SomeNamespace;
PhpCsFixer\Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer: ~
# control structure
# __CONSTRUCT() => __construct()
PhpCsFixer\Fixer\PhpUnit\PhpUnitMethodCasingFixer: ~
# __CLASS__ => self::class
SlevomatCodingStandard\Sniffs\Classes\ModernClassNameReferenceSniff: ~
# get_class() => __CLASS__
PhpCsFixer\Fixer\LanguageConstruct\FunctionToConstantFixer: ~
# "$var" => "${var}"
PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer: ~
PhpCsFixer\Fixer\LanguageConstruct\ExplicitIndirectVariableFixer: ~
# PSR-4
PhpCsFixer\Fixer\Basic\Psr4Fixer: ~
# private $one, $two;
PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer:
elements: ['property', 'const']
# new SomeClass;
PhpCsFixer\Fixer\Operator\NewWithBracesFixer: ~
# $value++; => ++$value;
PhpCsFixer\Fixer\Operator\StandardizeIncrementFixer: ~
# class SomeClass { ... return SomeClass; }
PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer: ~
# __dir__
PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer: ~
# if ($value = $this->someMethod()) { ... }
PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff: ~
# if (...) { return 1; } else { return 2; }
PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer: ~
# "value"
PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer: ~
# if ("result" === $value)
PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer:
equal: false
identical: false
less_and_greater: false
# private $property; public $anotherProperty;
PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer: ~
# use SomeTrait, AnotherTrait; → use SomeTrait;\nuse AnotherTrait;
SlevomatCodingStandard\Sniffs\Classes\TraitUseDeclarationSniff: ~
# valid function name sniff (snake case)
PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidFunctionNameSniff:
# valid variable name sniff (snake case)
PHP_CodeSniffer\Standards\Squiz\Sniffs\NamingConventions\ValidVariableNameSniff:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment