Advertisement
Guest User

phpcs config

a guest
Oct 18th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 9.08 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ruleset name="Hyra">
  3.     <description>
  4.         Extends PSR2 which extends PSR1.
  5.         Built with help from the PHP Coding Standards Generator https://edorian.github.io/php-coding-standard-generator/#phpcs
  6.         The Generator doesn't show every option, you'll need to check the PHP_Codesniffer repo to find all the sniffs and their options:
  7.         https://github.com/squizlabs/PHP_CodeSniffer
  8.     </description>
  9.     <exclude-pattern>src/Migrations/*</exclude-pattern>
  10.  
  11.     <arg name="tab-width" value="4" />
  12.  
  13.     <rule ref="PSR2" />
  14.  
  15.     <rule ref="Generic">
  16.         <!-- Short array syntax is da bomb -->
  17.         <exclude name="Generic.Arrays.DisallowShortArraySyntax" />
  18.         <!-- Need to allow unused parameters for overriding/implementing methods from parent classes -->
  19.         <exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />
  20.         <!-- Class opening braces should be on the next line -->
  21.         <exclude name="Generic.Classes.OpeningBraceSameLine.BraceOnNewLine" />
  22.         <!-- Complains about @var comments on instance variables -->
  23.         <exclude name="Generic.Commenting.DocComment.MissingShort" />
  24.         <!-- Complains about single line `/** @var */` comments on instance variables -->
  25.         <exclude name="Generic.Commenting.DocComment.ContentAfterOpen" />
  26.         <exclude name="Generic.Commenting.DocComment.ContentBeforeClose" />
  27.         <exclude name="Generic.Commenting.DocComment.SpacingBeforeTags" />
  28.         <!-- Complains about docblocks with Doctrine annotations -->
  29.         <exclude name="Generic.Commenting.DocComment.TagValueIndent" />
  30.         <!-- Filenames should not be lower case -->
  31.         <exclude name="Generic.Files.LowercasedFilename" />
  32.         <!-- Files should end with a newline -->
  33.         <exclude name="Generic.Files.EndFileNoNewline" />
  34.         <!-- Symfony says we want a space after casting -->
  35.         <exclude name="Generic.Formatting.NoSpaceAfterCast" />
  36.         <!-- Handled by php-cs-fixer -->
  37.         <exclude name="Generic.Formatting.MultipleStatementAlignment" />
  38.         <!-- This is extended by Squiz to handle multi line function calls -->
  39.         <exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman.BraceOnSameLine" />
  40.         <!-- We don't want the opening curly brace on the same line as the function definition -->
  41.         <exclude name="Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine" />
  42.         <!-- We want lower case for true, false and null -->
  43.         <exclude name="Generic.PHP.UpperCaseConstant" />
  44.         <!-- Opening PHP tags don't need closing PHP tags -->
  45.         <exclude name="Generic.PHP.ClosingPHPTag" />
  46.         <!-- Spaces, not tabs. We're not animals -->
  47.         <exclude name="Generic.WhiteSpace.DisallowSpaceIndent" />
  48.     </rule>
  49.  
  50.     <rule ref="MySource">
  51.         <!-- Functions should be allowed to return the result of another function -->
  52.         <exclude name="MySource.PHP.ReturnFunctionValue" />
  53.         <!-- Functions don't need comments if they're typed properly -->
  54.         <exclude name="MySource.Commenting.FunctionComment" />
  55.         <!-- We shouldn't be including anything, that's for the autoloader -->
  56.         <exclude name="MySource.Channels.IncludeSystem" />
  57.     </rule>
  58.  
  59.     <rule ref="PEAR">
  60.         <!-- The PEAR standard for comments is crazy -->
  61.         <exclude name="PEAR.Commenting.ClassComment" />
  62.         <exclude name="PEAR.Commenting.FileComment" />
  63.         <exclude name="PEAR.Commenting.FunctionComment" />
  64.         <!-- Use PSR-2 function call signature -->
  65.         <exclude name="PEAR.Functions.FunctionCallSignature" />
  66.         <!-- Private variables shouldn't have an underscore -->
  67.         <exclude name="PEAR.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
  68.         <!-- Private functions shouldn't have an underscore -->
  69.         <exclude name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore" />
  70.         <!-- PEAR switch/case indentation sucks and conflicts with generic -->
  71.         <exclude name="PEAR.WhiteSpace.ScopeIndent.IncorrectExact"/>
  72.     </rule>
  73.  
  74.     <rule ref="Squiz">
  75.         <!-- Allow arrays with single value to be multi-line -->
  76.         <exclude name="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed" />
  77.         <!-- Handled better by cs-fixer -->
  78.         <exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned" />
  79.         <!-- Allow `/** @var */` comments -->
  80.         <exclude name="Squiz.Commenting.BlockComment.WrongStart" />
  81.         <exclude name="Squiz.Commenting.InlineComment.DocBlock" />
  82.         <!-- Classes don't need comments -->
  83.         <exclude name="Squiz.Commenting.ClassComment" />
  84.         <!-- Files don't need comments -->
  85.         <exclude name="Squiz.Commenting.FileComment" />
  86.         <!-- Functions don't need comments if they're typed properly -->
  87.         <exclude name="Squiz.Commenting.FunctionComment" />
  88.         <!-- Sometimes you want a comment at the end of a line -->
  89.         <exclude name="Squiz.Commenting.PostStatementComment.Found" />
  90.         <!-- If the inline if needs brackets, it shouldn't be an inline if -->
  91.         <exclude name="Squiz.ControlStructures.InlineIfDeclaration.NoBrackets" />
  92.         <!-- No need to comment for closed functions, WTF? -->
  93.         <exclude name="Squiz.Commenting.ClosingDeclarationComment" />
  94.         <!-- Complains about Doctrine annotations -->
  95.         <exclude name="Squiz.Commenting.VariableComment.TagNotAllowed" />
  96.         <!-- Inline comments don't need to end with full-stops, exclamation marks or question marks -->
  97.         <exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
  98.         <!-- We don't want classes and interfaces in ".inc" files -->
  99.         <exclude name="Squiz.Files.FileExtension" />
  100.         <!-- Missing brackets are allowed, difficulty to understand should be picked up in PR -->
  101.         <exclude name="Squiz.Formatting.OperatorBracket" />
  102.         <!-- Private variables shouldn't have an underscore -->
  103.         <exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
  104.         <!-- Private functions shouldn't have an underscore -->
  105.         <exclude name="Squiz.NamingConventions.ValidFunctionName.PrivateNoUnderscore" />
  106.         <!-- Should be able to pass new object directly into function call -->
  107.         <exclude name="Squiz.Objects.ObjectInstantiation.NotAssigned" />
  108.         <!-- cs-fixer picks up implicit true better -->
  109.         <exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue" />
  110.         <!-- We want to be able to assign comparisons: $permission = $isAdmin || $canView -->
  111.         <exclude name="Squiz.PHP.DisallowComparisonAssignment" />
  112.         <!-- Boolean conditions in a return are fine  -->
  113.         <exclude name="Squiz.PHP.DisallowBooleanStatement" />
  114.         <!-- We want to use ternary's sometimes -->
  115.         <exclude name="Squiz.PHP.DisallowInlineIf" />
  116.         <!-- Complains about semicolons on the next line for multiline function calls -->
  117.         <exclude name="Squiz.WhiteSpace.SemicolonSpacing" />
  118.         <!-- Don't need a space before closing curly's -->
  119.         <exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeClose" />
  120.         <!-- Don't worry about function spacing -->
  121.         <exclude name="Squiz.WhiteSpace.FunctionSpacing" />
  122.         <!-- This argues with php-cs-fixer about int vs integer -->
  123.         <exclude name="Squiz.Commenting.VariableComment.IncorrectVarType" />
  124.         <!-- This is the indentation of break in a switch and conflicts with other rules -->
  125.         <exclude name="Squiz.ControlStructures.SwitchDeclaration.BreakIndent" />
  126.         <!-- We don't want to add //end switch to the end of long switch statements -->
  127.         <exclude name="Squiz.Commenting.LongConditionClosingComment.Missing" />
  128.     </rule>
  129.  
  130.     <rule ref="Zend">
  131.         <!-- Zend naming conventions are crazy -->
  132.         <exclude name="Zend.NamingConventions" />
  133.     </rule>
  134.  
  135.  
  136.     <!-- Special rules go down the bottom, to make sure they're overriding all of the above -->
  137.  
  138.     <!-- Generic -->
  139.  
  140.     <!-- Function name must be camel case -->
  141.     <rule ref="Generic.NamingConventions.CamelCapsFunctionName">
  142.         <properties>
  143.             <!-- Allow 2 capitals next to each other -->
  144.             <property name="strict" value="false" />
  145.         </properties>
  146.     </rule>
  147.  
  148.     <!-- PSR-2 says no hard limit, soft limit 120 -->
  149.     <rule ref="Generic.Files.LineLength">
  150.         <properties>
  151.             <property name="lineLimit" value="120"/>
  152.             <property name="absoluteLineLimit" value="0"/>
  153.         </properties>
  154.     </rule>
  155.  
  156.  
  157.     <!-- Squiz -->
  158.  
  159.     <!-- Object operators (->) are allowed to be on the next line -->
  160.     <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
  161.         <properties>
  162.             <property name="ignoreNewlines" value="true"/>
  163.         </properties>
  164.     </rule>
  165.  
  166.     <!-- No new lines required before the first instance variable -->
  167.     <rule ref="Squiz.WhiteSpace.MemberVarSpacing">
  168.         <properties>
  169.             <property name="spacingBeforeFirst" value="0"/>
  170.         </properties>
  171.     </rule>
  172. </ruleset>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement