|
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> |
| 2 | +<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="phpBB extension coding standard" xsi:noNamespaceSchemaLocation="phpcs.xsd" namespace="Phpbb"> |
| 3 | + <description>phpBB extension coding standard</description> |
| 4 | + |
| 5 | + <!-- |
| 6 | + 1.i. Editor Settings |
| 7 | + http://area51.phpbb.com/docs/32x/coding-guidelines.html#editorsettings |
| 8 | + --> |
| 9 | + <rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/> |
| 10 | + <rule ref="Generic.Files.LineEndings"/> |
| 11 | + |
| 12 | + <!-- |
| 13 | + 1.ii. File Layout |
| 14 | + http://area51.phpbb.com/docs/32x/coding-guidelines.html#fileheader |
| 15 | + --> |
| 16 | + <rule ref="PSR2.Files.ClosingTag"/> |
| 17 | + <rule ref="Generic.Files.EndFileNewline"/> |
| 18 | + |
| 19 | + <!-- |
| 20 | + 2.i. Variable/Function/Class Naming |
| 21 | + http://area51.phpbb.com/docs/32x/coding-guidelines.html#namingvars |
| 22 | + --> |
| 23 | + <!-- variable names are checked using Phpbb.NamingConventions.LowercaseUnderscoredVariables --> |
| 24 | + <!-- function names are checked using Phpbb.NamingConventions.LowercaseUnderscoredFunctions --> |
| 25 | + <!-- class names are checked using Phpbb.NamingConventions.LowercaseUnderscoredClasses --> |
| 26 | + <rule ref="Generic.Files.OneClassPerFile"/> |
| 27 | + <rule ref="Generic.Files.OneInterfacePerFile"/> |
| 28 | + <rule ref="Generic.Files.LowercasedFilename"/> |
| 29 | + <!-- TODO: create a sniff verifying that namespace matches directory structure --> |
| 30 | + |
| 31 | + <!-- |
| 32 | + 2.ii. Code Layout |
| 33 | + http://area51.phpbb.com/docs/32x/coding-guidelines.html#codelayout |
| 34 | + --> |
| 35 | + <rule ref="Generic.ControlStructures.InlineControlStructure"/> |
| 36 | + <rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman"/> |
| 37 | + <!-- opening brace for controls is checked using Phpbb.ControlStructure.OpeningBraceBsdAllman --> |
| 38 | + <!-- a space before opening parenthesis checked using Phpbb.ControlStructure.OpeningParenthesis --> |
| 39 | + <!-- TODO: create a sniff that checks for spaces between tokens --> |
| 40 | + <rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing"/> |
| 41 | + <rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/> |
| 42 | + <!-- TODO: create a sniff validating that break; is on the same level as case --> |
| 43 | + <rule ref="Squiz.Scope.MemberVarScope"/> |
| 44 | + <rule ref="Squiz.Scope.MethodScope"/> |
| 45 | + |
| 46 | + <!-- |
| 47 | + 2.vi. Restrictions on the Use of PHP |
| 48 | + http://area51.phpbb.com/docs/32x/coding-guidelines.html#phprestrictions |
| 49 | + --> |
| 50 | + <rule ref="Generic.PHP.DiscourageGoto"/> |
| 51 | + |
| 52 | + <!-- |
| 53 | + Other useful rules copied from phpbb repo |
| 54 | + --> |
| 55 | + <!-- The PHP constants true, false, and null MUST be in lower case. --> |
| 56 | + <rule ref="Generic.PHP.LowerCaseConstant"/> |
| 57 | + <!-- PHP keywords MUST be in lower case. --> |
| 58 | + <rule ref="Generic.PHP.LowerCaseKeyword"/> |
| 59 | + <!-- Constructors MUST be called __construct() instead of after the class. --> |
| 60 | + <rule ref="Generic.NamingConventions.ConstructorName"/> |
| 61 | + <!-- Classes etc. MUST be namespaced --> |
| 62 | + <rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace"/> |
| 63 | + <!-- Files containing classes MUST not have any side-effects --> |
| 64 | + <rule ref="PSR1.Files.SideEffects.FoundWithSymbols"/> |
| 65 | + <!-- When present, all use declarations MUST go after the namespace declaration. |
| 66 | + There MUST be one use keyword per declaration. |
| 67 | + There MUST be one blank line after the use block. --> |
| 68 | + <rule ref="PSR2.Namespaces.UseDeclaration"/> |
| 69 | + <!-- There MUST be one blank line after the namespace declaration --> |
| 70 | + <rule ref="PSR2.Namespaces.NamespaceDeclaration"/> |
| 71 | + <!-- "for (; bar; )" should be "while (bar)" instead --> |
| 72 | + <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/> |
| 73 | + <!-- A method MUST not only call its parent --> |
| 74 | + <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/> |
| 75 | + <!-- There MUST not be more than one statement per line. --> |
| 76 | + <rule ref="Generic.Formatting.DisallowMultipleStatements"/> |
| 77 | + <!-- Call-time pass-by-reference MUST not be used. --> |
| 78 | + <rule ref="Generic.Functions.CallTimePassByReference.NotAllowed"/> |
| 79 | + <!-- There MUST be exactly one space after a cast. --> |
| 80 | + <rule ref="Generic.Formatting.SpaceAfterCast"/> |
| 81 | + <!-- Class constants MUST be declared in all upper case with underscore separators. --> |
| 82 | + <rule ref="Generic.NamingConventions.UpperCaseConstantName"/> |
| 83 | + <!-- Only <?php, no short tags. --> |
| 84 | + <rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound"/> |
| 85 | + <!-- Method arguments with default values MUST go at the end of the argument list. --> |
| 86 | + <rule ref="PEAR.Functions.ValidDefaultValue"/> |
| 87 | + <!-- When referencing arrays there MUST NOT be any whitespace around the opening bracket |
| 88 | + or before the closing bracket. --> |
| 89 | + <rule ref="Squiz.Arrays.ArrayBracketSpacing"/> |
| 90 | + <!-- The "else if" statement MUST be written with a space between the words else and if. --> |
| 91 | + <rule ref="Squiz.ControlStructures.ElseIfDeclaration"/> |
| 92 | + <!-- There MUST be a space between each element of a foreach loop. --> |
| 93 | + <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/> |
| 94 | + <!-- In a for loop declaration, there MUST be no space inside the brackets |
| 95 | + and there MUST be 0 spaces before and 1 space after semicolons. --> |
| 96 | + <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/> |
| 97 | + <!-- In the argument list, there MUST NOT be a space before each comma, |
| 98 | + and there MUST be one space after each comma. --> |
| 99 | + <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing"> |
| 100 | + <properties> |
| 101 | + <property name="equalsSpacing" value="1"/> |
| 102 | + </properties> |
| 103 | + </rule> |
| 104 | + <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint"/> |
| 105 | + <!-- All built-in PHP functions MUST be called lowercased. --> |
| 106 | + <rule ref="Squiz.Functions.LowercaseFunctionKeywords"/> |
| 107 | + <!-- The eval() function MUST NOT be used. --> |
| 108 | + <rule ref="Squiz.PHP.Eval"/> |
| 109 | + <!-- There MUST NOT be trailing whitespace at the end of lines. --> |
| 110 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/> |
| 111 | + <!-- There MUST NOT be whitespace before the first content of a file --> |
| 112 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile"/> |
| 113 | + <!-- There MUST NOT be whitespace after the last content of a file --> |
| 114 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile"/> |
| 115 | + <!-- Functions MUST NOT contain multiple empty lines in a row --> |
| 116 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"/> |
| 117 | + <!-- All code files MUST use only UTF-8 without BOM. --> |
| 118 | + <rule ref="Generic.Files.ByteOrderMark"/> |
| 119 | +</ruleset> |
0 commit comments