Skip to content

Commit 4cda118

Browse files
authored
Merge pull request #33 from ConvertKit/coding-standards
Apply Coding Standards
2 parents eab7d04 + 2664982 commit 4cda118

File tree

3 files changed

+430
-252
lines changed

3 files changed

+430
-252
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ jobs:
6464
- name: Build PHP Autoloader
6565
run: composer dump-autoload
6666

67+
# Run Coding Standards.
68+
- name: Run Coding Standards
69+
run: php vendor/bin/phpcs --standard=phpcs.xml
70+
6771
# Run Coding Standards on Tests.
6872
- name: Run Coding Standards on Tests
6973
run: php vendor/bin/phpcs --standard=phpcs.tests.xml

phpcs.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
3+
<description>Coding Standards</description>
4+
5+
<!-- Inspect files in the /src folder -->
6+
<file>src</file>
7+
8+
<!-- Run in verbose mode and specify the precise rule that failed in output -->
9+
<arg value="sv"/>
10+
<arg name="colors"/>
11+
12+
<!-- Use PSR-12 -->
13+
<rule ref="PSR12">
14+
<!-- Exclude function not in camel caps format, to avoid breaking changes -->
15+
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
16+
17+
<!-- Don't require spacing after header block -->
18+
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock" />
19+
20+
<!-- Permit else if over elseif -->
21+
<exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed" />
22+
</rule>
23+
24+
<!-- Use Squiz -->
25+
<rule ref="Squiz">
26+
<!-- Exclude "Class found in ".php" file; use ".inc" extension instead" -->
27+
<exclude name="Squiz.Files.FileExtension.ClassFound" />
28+
29+
<!-- Exclude PascalCase format for class name, to avoid breaking changes -->
30+
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
31+
32+
<!-- Exclude variable naming, to avoid breaking changes -->
33+
<exclude name="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps" />
34+
<exclude name="Squiz.NamingConventions.ValidVariableName.NotCamelCaps" />
35+
<exclude name="Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps" />
36+
37+
<!-- Allow implicit true and false comparisons -->
38+
<exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue" />
39+
<exclude name="Squiz.Operators.ComparisonOperatorUsage.NotAllowed" />
40+
41+
<!-- Don't require // end comments after each function, or Author / Copyright tags -->
42+
<exclude name="Squiz.Commenting.ClosingDeclarationComment.Missing" />
43+
<exclude name="Squiz.Commenting.FileComment.IncorrectAuthor" />
44+
<exclude name="Squiz.Commenting.FileComment.MissingCopyrightTag" />
45+
46+
<!-- Permit inline if statements -->
47+
<exclude name="Squiz.PHP.DisallowInlineIf.Found" />
48+
49+
<!-- Don't require various newlines and spacing before and after functions -->
50+
<exclude name="Squiz.WhiteSpace.FunctionSpacing.AfterLast" />
51+
<exclude name="Squiz.WhiteSpace.FunctionSpacing.After" />
52+
<exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeClose" />
53+
<exclude name="Squiz.WhiteSpace.MemberVarSpacing.FirstIncorrect" />
54+
55+
<!-- Permit padding surrounding a concat operator -->
56+
<exclude name="Squiz.Strings.ConcatenationSpacing.PaddingFound" />
57+
</rule>
58+
</ruleset>

0 commit comments

Comments
 (0)