Skip to content

Commit b801021

Browse files
committed
Add configuration for PHP Codesniffer.
1 parent f1db07d commit b801021

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

build/phpcs.xml.dist

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0"?>
2+
<ruleset
3+
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
name="PDS Interop"
6+
>
7+
<description>PHP coding standards for PDS Interop projects</description>
8+
9+
<!-- Show sniff codes in all reports, and progress when running -->
10+
<arg value="sp"/>
11+
<!-- Strip the filepaths down to the relevant bit. -->
12+
<arg name="basepath" value="../solid/"/>
13+
<arg name="extensions" value="php"/>
14+
<arg name="colors"/>
15+
<!-- <arg name="parallel" value="75"/>-->
16+
17+
<file>.</file>
18+
<exclude-pattern>*/vendor/*|*/build/*</exclude-pattern>
19+
20+
<rule ref="PHPCompatibility"/>
21+
<config name="testVersion" value="7.3-"/>
22+
23+
<!-- Include the whole PSR-12 standard -->
24+
<rule ref="PSR12">
25+
<!-- Until things have been cleaned up a bit, these violations are allowed -->
26+
<exclude name="Generic.Files.LineLength.TooLong"/>
27+
<exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame"/>
28+
<exclude name="Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma"/>
29+
<exclude name="Generic.WhiteSpace.DisallowTabIndent.NonIndentTabsUsed"/>
30+
<exclude name="Generic.WhiteSpace.DisallowTabIndent.TabsUsed"/>
31+
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect"/>
32+
<exclude name="Generic.WhiteSpace.ScopeIndent.IncorrectExact"/>
33+
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
34+
<exclude name="PSR12.Files.FileHeader.SpacingInsideBlock"/>
35+
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>
36+
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
37+
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody"/>
38+
<exclude name="PSR2.Classes.ClassDeclaration.OpenBraceNewLine"/>
39+
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword"/>
40+
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceAfterEquals"/>
41+
<exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpaceBeforeEquals"/>
42+
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine"/>
43+
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace"/>
44+
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction"/>
45+
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.Indent"/>
46+
<exclude name="Squiz.WhiteSpace.SuperfluousWhitespace.EndLine"/>
47+
</rule>
48+
49+
<!-- Have 12 chars padding maximum and always show as errors -->
50+
<rule ref="Generic.Formatting.MultipleStatementAlignment">
51+
<properties>
52+
<property name="maxPadding" value="12"/>
53+
<property name="error" value="true"/>
54+
</properties>
55+
</rule>
56+
<!-- Original PHP function should be used rather than an alias -->
57+
<rule ref="Generic.PHP.ForbiddenFunctions">
58+
<properties>
59+
<property name="forbiddenFunctions" type="array">
60+
<element key="chop" value="rtrim"/>
61+
<element key="doubleval" value="floatval"/>
62+
<element key="fputs" value="fwrite"/>
63+
<element key="ini_alter" value="ini_set"/>
64+
<element key="is_integer" value="is_int"/>
65+
<element key="is_real" value="is_float"/>
66+
<element key="is_writeable" value="is_writable"/>
67+
<element key="join" value="implode"/>
68+
<element key="key_exists" value="array_key_exists"/>
69+
<element key="pos" value="current"/>
70+
<element key="posix_errno" value="posix_get_last_error"/>
71+
<element key="recode" value="recode_string"/>
72+
<element key="session_commit" value="session_write_close"/>
73+
<element key="set_file_buffer" value="stream_set_write_buffer"/>
74+
<element key="show_source" value="highlight_file"/>
75+
<element key="sizeof" value="count"/>
76+
<element key="strchr" value="strstr"/>
77+
<element key="user_error" value="trigger_error"/>
78+
</property>
79+
</properties>
80+
</rule>
81+
</ruleset>

0 commit comments

Comments
 (0)