Skip to content

Commit 9b5226b

Browse files
committed
Fix phpcs workflow
1 parent 6510515 commit 9b5226b

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ runs:
2121
with:
2222
php-version: ${{ inputs.php-version }}
2323
extensions: "mongodb-${{ inputs.driver-version }}"
24-
key: "extcache-v1"
24+
key: "extcache-${{ inputs.driver-version }}"
2525

2626
- name: Cache extensions
2727
uses: actions/cache@v4

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
paths:
66
- "source/**/*.php"
77
- ".github/workflows/*.yml"
8+
- ".github/actions/**"
89

910
env:
1011
PHP_VERSION: "8.2"

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
paths:
66
- "source/**/*.php"
77
- ".github/workflows/*.yml"
8+
- ".github/actions/**"
89
workflow_call:
910
inputs:
1011
ref:

phpcs.xml.dist

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0"?>
2+
<ruleset>
3+
<arg name="basepath" value="." />
4+
<arg name="extensions" value="php" />
5+
<arg name="parallel" value="80" />
6+
<arg name="cache" value=".phpcs-cache" />
7+
<arg name="colors" />
8+
9+
<!-- Ignore warnings (n), show progress of the run (p), and show sniff names (s) -->
10+
<arg value="nps"/>
11+
12+
<file>source</file>
13+
14+
<!-- Target minimum supported PHP version -->
15+
<config name="php_version" value="80100"/>
16+
17+
<!-- ****************************************** -->
18+
<!-- Import rules from doctrine/coding-standard -->
19+
<!-- ****************************************** -->
20+
<rule ref="Doctrine">
21+
<!-- ******************************************** -->
22+
<!-- Exclude sniffs we simply don't want for docs -->
23+
<!-- ******************************************** -->
24+
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
25+
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly" />
26+
<exclude name="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps" />
27+
<!-- Results in false positives with comments used to denote include blocks -->
28+
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountAfterControlStructure" />
29+
<exclude name="Squiz.Classes.ClassFileName.NoMatch" />
30+
31+
<!-- *********************************** -->
32+
<!-- Exclude sniffs that cause BC breaks -->
33+
<!-- *********************************** -->
34+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming" />
35+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming" />
36+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming" />
37+
<exclude name="SlevomatCodingStandard.Classes.SuperfluousTraitNaming" />
38+
39+
<!-- Can cause subtle BC breaks -->
40+
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" />
41+
42+
43+
<!-- **************************************** -->
44+
<!-- Exclude sniffs that force unwanted style -->
45+
<!-- **************************************** -->
46+
<exclude name="Generic.Formatting.MultipleStatementAlignment" />
47+
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop" />
48+
<exclude name="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat.DisallowedShortNullable" />
49+
50+
<!-- Keep long typehints (for now) -->
51+
<exclude name="PSR12.Keywords.ShortFormTypeKeywords" />
52+
<exclude name="SlevomatCodingStandard.PHP.TypeCast.InvalidCastUsed" />
53+
<exclude name="SlevomatCodingStandard.TypeHints.LongTypeHints" />
54+
55+
56+
<!-- ************************************************ -->
57+
<!-- Exclude sniffs that may cause functional changes -->
58+
<!-- ************************************************ -->
59+
<exclude name="Generic.PHP.ForbiddenFunctions.FoundWithAlternative" />
60+
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
61+
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit" />
62+
<exclude name="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" />
63+
<exclude name="SlevomatCodingStandard.Functions.StaticClosure" />
64+
<exclude name="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
65+
<exclude name="SlevomatCodingStandard.Operators.DisallowEqualOperators" />
66+
67+
68+
<!-- ********************************************************* -->
69+
<!-- Exclude sniffs that cause a huge diff - enable separately -->
70+
<!-- ********************************************************* -->
71+
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectAnnotationsGroup" />
72+
73+
74+
<!-- ********************* -->
75+
<!-- Exclude broken sniffs -->
76+
<!-- ********************* -->
77+
78+
<!-- Sniff currently broken when casting arrays, see https://github.com/squizlabs/PHP_CodeSniffer/issues/2937#issuecomment-615498860 -->
79+
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline" />
80+
81+
<!-- Disable forbidden annotation sniff as excluding @api from the list doesn't work -->
82+
<exclude name="SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden" />
83+
</rule>
84+
85+
86+
<!-- **************************************** -->
87+
<!-- Enable rules not enforced by Doctrine CS -->
88+
<!-- **************************************** -->
89+
90+
<!-- Require arrow functions where possible -->
91+
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>
92+
93+
94+
<!-- ****************************************************** -->
95+
<!-- Don't require annotations to specify traversable types -->
96+
<!-- ****************************************************** -->
97+
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
98+
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
99+
</rule>
100+
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
101+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
102+
</rule>
103+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
104+
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
105+
</rule>
106+
107+
</ruleset>

0 commit comments

Comments
 (0)