Skip to content

Commit 7777d15

Browse files
committed
Create Respect Coding Standard
This coding standard is already being used by Respect\Validation. This repository should contain all coding standards used by other Respect components as well. There are no tests for now. Since that's what Validation is using, I decide to see how it will work. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
0 parents  commit 7777d15

File tree

6 files changed

+210
-0
lines changed

6 files changed

+210
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.lock
2+
vendor/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Henrique Moody <henriquemoody@gmail.com>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Respect Coding Standard
2+
3+
The Respect Coding Standard is a set of [PHP_CodeSniffer][] rules
4+
applied the Respect components.
5+
6+
[PHP_CodeSniffer]: https://github.com/squizlabs/PHP_CodeSniffer

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "respect/coding-standard",
3+
"type": "phpcodesniffer-standard",
4+
"description": "The Respect Coding Standard is a set of PHP_CodeSniffer rules applied the Respect components.",
5+
"keywords": ["respect", "coding", "standard"],
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Henrique Moody",
10+
"email": "henriquemoody@gmail.com"
11+
}
12+
],
13+
"require": {
14+
"php": "^7.1 || ^8.0",
15+
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
16+
"escapestudios/symfony2-coding-standard": "^3.8",
17+
"slevomat/coding-standard": "^5.0",
18+
"squizlabs/php_codesniffer": "^3.4"
19+
},
20+
"config": {
21+
"sort-packages": true
22+
}
23+
}

src/Respect/ruleset.xml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?xml version="1.0"?>
2+
<ruleset
3+
name="Respect Coding Standard"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd">
6+
7+
<description>A set of PHP_CodeSniffer rules applied the Respect components.</description>
8+
9+
<rule ref="PSR1" />
10+
<rule ref="PSR2" />
11+
<rule ref="Generic.Arrays.ArrayIndent" />
12+
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
13+
<rule ref="Generic.Formatting.SpaceAfterNot">
14+
<properties>
15+
<property name="spacing" value="0" />
16+
</properties>
17+
</rule>
18+
<rule ref="Generic.NamingConventions.CamelCapsFunctionName" />
19+
<rule ref="Generic.PHP.NoSilencedErrors" />
20+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
21+
<properties>
22+
<property name="allowMultiline" value="true" />
23+
</properties>
24+
</rule>
25+
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing" />
26+
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing" />
27+
<rule ref="PEAR.WhiteSpace.ObjectOperatorIndent" />
28+
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation" />
29+
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma" />
30+
<rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility" />
31+
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants" />
32+
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference" />
33+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming" />
34+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming" />
35+
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration" />
36+
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
37+
<properties>
38+
<property name="linesCountBeforeFirstUse" value="0" />
39+
</properties>
40+
</rule>
41+
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition" />
42+
<rule ref="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing">
43+
<properties>
44+
<property name="tokensToCheck" type="array">
45+
<element value="T_RETURN" />
46+
</property>
47+
</properties>
48+
</rule>
49+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch" />
50+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
51+
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit" />
52+
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses" />
53+
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses" />
54+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />
55+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator" />
56+
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator" />
57+
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" />
58+
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator" />
59+
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch" />
60+
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly" />
61+
<rule ref="SlevomatCodingStandard.Functions.StaticClosure" />
62+
<rule ref="SlevomatCodingStandard.Functions.UselessParameterDefaultValue" />
63+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
64+
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse" />
65+
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration" />
66+
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing" />
67+
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
68+
<properties>
69+
<property name="allowFallbackGlobalConstants" value="false"/>
70+
<property name="allowFallbackGlobalFunctions" value="false"/>
71+
<property name="allowFullyQualifiedGlobalClasses" value="false"/>
72+
<property name="allowFullyQualifiedGlobalConstants" value="false"/>
73+
<property name="allowFullyQualifiedGlobalFunctions" value="false"/>
74+
<property name="allowFullyQualifiedNameForCollidingClasses" value="true"/>
75+
<property name="allowFullyQualifiedNameForCollidingConstants" value="true"/>
76+
<property name="allowFullyQualifiedNameForCollidingFunctions" value="true"/>
77+
<property name="searchAnnotations" value="true"/>
78+
</properties>
79+
</rule>
80+
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile" />
81+
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
82+
<properties>
83+
<property name="searchAnnotations" value="true" />
84+
</properties>
85+
</rule>
86+
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash" />
87+
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace" />
88+
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias" />
89+
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing" />
90+
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking" />
91+
<rule ref="SlevomatCodingStandard.PHP.ShortList" />
92+
<rule ref="SlevomatCodingStandard.PHP.TypeCast" />
93+
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses" />
94+
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon" />
95+
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing" />
96+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
97+
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
98+
<properties>
99+
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2" />
100+
<property name="spacesCountAroundEqualsSign" value="0" />
101+
</properties>
102+
</rule>
103+
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
104+
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
105+
<properties>
106+
<property name="allAnnotationsAreUseful" value="true" />
107+
<property name="enableEachParameterAndReturnInspection" value="true" />
108+
</properties>
109+
</rule>
110+
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" />
111+
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable" />
112+
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable" />
113+
<rule ref="SlevomatCodingStandard.Variables.UselessVariable" />
114+
<rule ref="Squiz.PHP.CommentedOutCode" />
115+
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
116+
<properties>
117+
<property name="spacing" value="1" />
118+
<property name="spacingBeforeFirst" value="0" />
119+
<property name="spacingAfterLast" value="0" />
120+
</properties>
121+
</rule>
122+
<rule ref="Squiz.Strings.ConcatenationSpacing">
123+
<properties>
124+
<property name="spacing" value="0" />
125+
<property name="ignoreNewlines" value="true" />
126+
</properties>
127+
</rule>
128+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
129+
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
130+
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
131+
</rule>
132+
<rule ref="Squiz.WhiteSpace.MemberVarSpacing">
133+
<properties>
134+
<property name="spacing" value="1" />
135+
<property name="spacingBeforeFirst" value="0" />
136+
</properties>
137+
</rule>
138+
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
139+
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing" />
140+
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
141+
<properties>
142+
<property name="ignoreNewlines" value="true" />
143+
</properties>
144+
</rule>
145+
<rule ref="Squiz.WhiteSpace.OperatorSpacing" />
146+
<rule ref="Squiz.WhiteSpace.SemicolonSpacing" />
147+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
148+
<properties>
149+
<property name="ignoreBlankLines" value="false" />
150+
</properties>
151+
</rule>
152+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
153+
<severity>5</severity>
154+
</rule>
155+
<rule ref="Symfony.Functions.ScopeOrder" />
156+
</ruleset>

0 commit comments

Comments
 (0)