Skip to content

Apply Coding Standards #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ jobs:
- name: Build PHP Autoloader
run: composer dump-autoload

# Run Coding Standards.
- name: Run Coding Standards
run: php vendor/bin/phpcs --standard=phpcs.xml

# Run Coding Standards on Tests.
- name: Run Coding Standards on Tests
run: php vendor/bin/phpcs --standard=phpcs.tests.xml
Expand Down
58 changes: 58 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer" xsi:noNamespaceSchemaLocation="phpcs.xsd">
<description>Coding Standards</description>

<!-- Inspect files in the /src folder -->
<file>src</file>

<!-- Run in verbose mode and specify the precise rule that failed in output -->
<arg value="sv"/>
<arg name="colors"/>

<!-- Use PSR-12 -->
<rule ref="PSR12">
<!-- Exclude function not in camel caps format, to avoid breaking changes -->
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />

<!-- Don't require spacing after header block -->
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock" />

<!-- Permit else if over elseif -->
<exclude name="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed" />
</rule>

<!-- Use Squiz -->
<rule ref="Squiz">
<!-- Exclude "Class found in ".php" file; use ".inc" extension instead" -->
<exclude name="Squiz.Files.FileExtension.ClassFound" />

<!-- Exclude PascalCase format for class name, to avoid breaking changes -->
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />

<!-- Exclude variable naming, to avoid breaking changes -->
<exclude name="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps" />
<exclude name="Squiz.NamingConventions.ValidVariableName.NotCamelCaps" />
<exclude name="Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps" />

<!-- Allow implicit true and false comparisons -->
<exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue" />
<exclude name="Squiz.Operators.ComparisonOperatorUsage.NotAllowed" />

<!-- Don't require // end comments after each function, or Author / Copyright tags -->
<exclude name="Squiz.Commenting.ClosingDeclarationComment.Missing" />
<exclude name="Squiz.Commenting.FileComment.IncorrectAuthor" />
<exclude name="Squiz.Commenting.FileComment.MissingCopyrightTag" />

<!-- Permit inline if statements -->
<exclude name="Squiz.PHP.DisallowInlineIf.Found" />

<!-- Don't require various newlines and spacing before and after functions -->
<exclude name="Squiz.WhiteSpace.FunctionSpacing.AfterLast" />
<exclude name="Squiz.WhiteSpace.FunctionSpacing.After" />
<exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeClose" />
<exclude name="Squiz.WhiteSpace.MemberVarSpacing.FirstIncorrect" />

<!-- Permit padding surrounding a concat operator -->
<exclude name="Squiz.Strings.ConcatenationSpacing.PaddingFound" />
</rule>
</ruleset>
Loading