Skip to content

Commit 927d5d8

Browse files
committed
:octocat: fix broken PHPCS ruleset
1 parent 634bb72 commit 927d5d8

11 files changed

+151
-118
lines changed

examples/Providers/Spotify/SpotifyClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function saveToFile(array $vars, string $dir):void{
3939
foreach($vars as $var){
4040
file_put_contents(
4141
sprintf('%s/%s.json', rtrim($dir, '\\/'), $var),
42-
json_encode($this->{$var}, (JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE))
42+
json_encode($this->{$var}, (JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE))
4343
);
4444
}
4545

examples/Providers/Spotify/mixesdb-scrape.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@
114114
}
115115
while(!empty($catPath));
116116

117-
file_put_contents($file, json_encode($tracklist, (JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE)));
117+
file_put_contents($file, json_encode($tracklist, (JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)));

examples/Providers/Spotify/new-releases.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
$skipAppearsOn = true;
2828
$skipVariousArtist = true;
2929
$fromCache = false;
30-
$cacheDir = __DIR__.'/cache';
30+
$cacheDir = __DIR__.'/cache';
3131

3232
$spotify = $factory->getProvider(SpotifyNewReleases::class, OAuthExampleProviderFactory::STORAGE_FILE);
3333
$spotify->getNewReleases($since, $until, $minTracks, $skipVariousArtist, $skipAppearsOn, $fromCache, $cacheDir);

phpcs.xml.dist

+136-113
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,123 @@
11
<?xml version="1.0"?>
2-
<ruleset name="php-oauth-cs"
2+
<ruleset name="php-qrcode-cs"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
5-
<description>php-oauth rules for phpcs</description>
5+
<description>php-qrcode rules for phpcs</description>
66

77
<file>examples</file>
88
<file>src</file>
99
<file>tests</file>
1010

11+
<arg value="ps"/>
12+
<arg name="parallel" value="8"/>
13+
<!--<arg name="cache" value=".build/phpcs.cache"/>-->
14+
1115
<arg name="basepath" value="."/>
16+
<arg name="extensions" value="php"/>
1217
<arg name="tab-width" value="4"/>
1318

1419
<rule ref="Internal.Tokenizer.Exception">
1520
<type>error</type>
1621
</rule>
1722

23+
<!--
24+
PHPCS built-in https://tentyp.dev/library/php/phpcs/
25+
-->
26+
27+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
28+
<rule ref="Generic.Classes.DuplicateClassName"/>
29+
<rule ref="Generic.CodeAnalysis.AssignmentInCondition"/>
30+
<rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/>
31+
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
32+
<rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
33+
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
34+
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
35+
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
36+
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
37+
<rule ref="Generic.Commenting.Fixme"/>
38+
<!--<rule ref="Generic.Commenting.Todo"/>-->
39+
<rule ref="Generic.ControlStructures.InlineControlStructure"/>
40+
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
41+
<!--<rule ref="Generic.Formatting.MultipleStatementAlignment"/>-->
42+
<rule ref="Generic.Formatting.NoSpaceAfterCast"/>
43+
<rule ref="Generic.Functions.CallTimePassByReference"/>
44+
<!--<rule ref="Generic.NamingConventions.InterfaceNameSuffix"/>-->
45+
<rule ref="Generic.NamingConventions.TraitNameSuffix"/>
46+
<rule ref="Generic.PHP.BacktickOperator"/>
47+
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
48+
<rule ref="Generic.PHP.DeprecatedFunctions"/>
49+
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
50+
<rule ref="Generic.PHP.DisallowRequestSuperglobal"/>
51+
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
52+
<rule ref="Generic.PHP.DiscourageGoto"/>
53+
<rule ref="Generic.PHP.LowerCaseConstant"/>
54+
<rule ref="Generic.PHP.LowerCaseKeyword"/>
55+
<rule ref="Generic.PHP.LowerCaseType"/>
56+
<rule ref="Generic.PHP.NoSilencedErrors"/>
57+
<rule ref="Generic.PHP.RequireStrictTypes"/>
58+
<rule ref="Generic.PHP.SAPIUsage"/>
59+
<rule ref="Generic.PHP.Syntax"/>
60+
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
61+
<!--<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>-->
62+
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
63+
<rule ref="Generic.WhiteSpace.ScopeIndent"/>
64+
<rule ref="Generic.WhiteSpace.SpreadOperatorSpacingAfter"/>
65+
66+
<rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
67+
<rule ref="PSR2.Files.ClosingTag"/>
68+
<rule ref="PSR2.Files.EndFileNewline"/>
69+
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
70+
71+
<!--<rule ref="PSR12.Classes.AnonClassDeclaration"/>-->
72+
<rule ref="PSR12.Classes.ClosingBrace"/>
73+
<rule ref="PSR12.Files.OpenTag"/>
74+
<rule ref="PSR12.Functions.NullableTypeDeclaration"/>
75+
76+
77+
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
78+
<rule ref="Squiz.Classes.DuplicateProperty"/>
79+
<rule ref="Squiz.Classes.LowercaseClassKeywords"/>
80+
<rule ref="Squiz.Classes.SelfMemberReference"/>
81+
<rule ref="Squiz.Commenting.DocCommentAlignment"/>
82+
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
83+
<!--<rule ref="Squiz.Commenting.FunctionCommentThrowTag"/>-->
84+
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
85+
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
86+
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
87+
<rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
88+
<rule ref="Squiz.Formatting.OperatorBracket"/>
89+
<rule ref="Squiz.Functions.FunctionDeclaration"/>
90+
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
91+
<rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
92+
<rule ref="Squiz.Operators.IncrementDecrementUsage"/>
93+
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
94+
<rule ref="Squiz.PHP.DisallowMultipleAssignments"/>
95+
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
96+
<rule ref="Squiz.PHP.Eval"/>
97+
<rule ref="Squiz.PHP.InnerFunctions"/>
98+
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
99+
<rule ref="Squiz.PHP.NonExecutableCode"/>
100+
<rule ref="Squiz.Scope.MemberVarScope"/>
101+
<rule ref="Squiz.Scope.MethodScope"/>
102+
<rule ref="Squiz.Scope.StaticThisUsage"/>
103+
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
104+
<rule ref="Squiz.Strings.EchoedStrings"/>
105+
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
106+
107+
<rule ref="Squiz.PHP.GlobalKeyword">
108+
<exclude-pattern>examples</exclude-pattern>
109+
</rule>
18110

19-
<rule ref="Generic">
20-
<exclude name="Generic.Arrays.DisallowShortArraySyntax" />
21-
<exclude name="Generic.CodeAnalysis.EmptyStatement" />
22-
<exclude name="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
23-
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter" />
24-
<exclude name="Generic.Commenting.Todo" />
25-
<exclude name="Generic.ControlStructures.InlineControlStructure" />
26-
<exclude name="Generic.Debug" />
27-
<exclude name="Generic.Files.EndFileNoNewline" />
28-
<exclude name="Generic.Files.LowercasedFilename" />
29-
<exclude name="Generic.Formatting.SpaceBeforeCast" />
30-
<exclude name="Generic.Functions.OpeningFunctionBraceBsdAllman" />
31-
<exclude name="Generic.NamingConventions.AbstractClassNamePrefix" />
32-
<exclude name="Generic.NamingConventions.CamelCapsFunctionName" />
33-
<exclude name="Generic.PHP.ClosingPHPTag" />
34-
<exclude name="Generic.PHP.RequireStrictTypes" />
35-
<exclude name="Generic.PHP.UpperCaseConstant" />
36-
<exclude name="Generic.VersionControl" />
37-
<exclude name="Generic.WhiteSpace.DisallowTabIndent" />
38-
<exclude name="Generic." />
111+
<rule ref="PSR1.Files.SideEffects">
112+
<exclude-pattern>examples</exclude-pattern>
113+
<exclude-pattern>benchmark</exclude-pattern>
39114
</rule>
40115

116+
117+
<!--
118+
Configurable built-in https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties
119+
-->
120+
41121
<rule ref="Generic.ControlStructures.InlineControlStructure">
42122
<properties>
43123
<property name="error" value="true"/>
@@ -46,10 +126,17 @@
46126

47127
<rule ref="Generic.Files.LineLength">
48128
<properties>
49-
<property name="lineLimit" value="130" />
129+
<property name="lineLimit" value="140" />
50130
<property name="absoluteLineLimit" value="160" />
51131
<property name="ignoreComments" value="true" />
52132
</properties>
133+
<exclude-pattern>examples</exclude-pattern>
134+
</rule>
135+
136+
<rule ref="Generic.Formatting.SpaceAfterNot">
137+
<properties>
138+
<property name="spacing" value="0" />
139+
</properties>
53140
</rule>
54141

55142
<rule ref="Generic.PHP.ForbiddenFunctions">
@@ -65,126 +152,62 @@
65152
</properties>
66153
</rule>
67154

68-
<rule ref="Generic.Formatting.SpaceAfterCast">
155+
<rule ref="Generic.Strings.UnnecessaryStringConcat">
69156
<properties>
70-
<property name="spacing" value="0" />
157+
<property name="allowMultiline" value="true" />
71158
</properties>
72159
</rule>
73160

74-
<rule ref="Generic.Formatting.SpaceAfterNot">
161+
<rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing">
75162
<properties>
76-
<property name="spacing" value="0" />
163+
<property name="ignoreNewlines" value="true" />
77164
</properties>
78165
</rule>
79166

80167
<rule ref="Generic.WhiteSpace.ScopeIndent">
81168
<properties>
82169
<property name="tabIndent" value="true" />
170+
<property name="ignoreIndentationTokens" type="array">
171+
<element value="T_COMMENT"/>
172+
<element value="T_DOC_COMMENT_OPEN_TAG"/>
173+
</property>
83174
</properties>
84175
</rule>
85176

86-
87-
<rule ref="PEAR">
88-
<exclude name="PEAR.Classes" />
89-
<exclude name="PEAR.Commenting" />
90-
<exclude name="PEAR.ControlStructures" />
91-
<exclude name="PEAR.Functions.FunctionCallSignature" />
92-
<exclude name="PEAR.Functions.FunctionDeclaration" />
93-
<exclude name="PEAR.NamingConventions" />
94-
<exclude name="PEAR.WhiteSpace.ScopeIndent" />
95-
</rule>
96-
97-
<rule ref="PEAR.Commenting.FunctionComment">
177+
<rule ref="PSR12.ControlStructures.BooleanOperatorPlacement">
98178
<properties>
99-
<property name="minimumVisibility" value="public" />
179+
<property name="allowOnly" value="first" />
100180
</properties>
101181
</rule>
102182

103-
104-
<rule ref="PSR2">
105-
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
106-
107-
<exclude name="PSR2.Classes.ClassDeclaration" />
108-
<exclude name="PSR2.ControlStructures.ControlStructureSpacing" />
109-
<exclude name="PSR2.ControlStructures.SwitchDeclaration" />
110-
<exclude name="PSR2.Methods.FunctionClosingBrace" />
111-
<exclude name="PSR2.Namespaces.UseDeclaration.MultipleDeclarations" />
112-
</rule>
113-
114-
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
115-
<type>error</type>
116-
</rule>
117-
118-
<rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
119-
<type>error</type>
120-
</rule>
121-
122-
123-
<rule ref="PSR12">
124-
<exclude name="PSR12.Classes.ClassInstantiation" />
125-
<exclude name="PSR12.Classes.OpeningBraceSpace" />
126-
<exclude name="PSR12.ControlStructures" />
127-
<exclude name="PSR12.Files.FileHeader.SpacingInsideBlock" />
128-
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock" />
129-
<exclude name="PSR12.Functions.ReturnTypeDeclaration" />
130-
<exclude name="PSR12.Operators.OperatorSpacing" />
131-
<exclude name="PSR12.Traits.UseDeclaration.MultipleImport" />
132-
</rule>
133-
134183
<rule ref="PSR12.Namespaces.CompoundNamespaceDepth">
135184
<properties>
136185
<property name="maxDepth" value="1" />
137186
</properties>
138187
</rule>
139188

140-
<rule ref="Squiz">
141-
<exclude name="Squiz.Arrays.ArrayDeclaration.IndexNoNewline" />
142-
<exclude name="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed" />
143-
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed" />
144-
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline" />
145-
<exclude name="Squiz.Classes.ClassDeclaration" />
146-
<exclude name="Squiz.Commenting" />
147-
<exclude name="Squiz.ControlStructures.ControlSignature" />
148-
<exclude name="Squiz.ControlStructures.ElseIfDeclaration" />
149-
<exclude name="Squiz.ControlStructures.InlineIfDeclaration.NotSingleLine" />
150-
<exclude name="Squiz.ControlStructures.SwitchDeclaration" />
151-
<exclude name="Squiz.Files" />
152-
<exclude name="Squiz.Functions" />
153-
<exclude name="Squiz.NamingConventions.ValidVariableName.NotCamelCaps" />
154-
<exclude name="Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps" />
155-
<exclude name="Squiz.NamingConventions.ValidFunctionName.ScopeNotCamelCaps" />
156-
<exclude name="Squiz.Objects.ObjectInstantiation.NotAssigned" />
157-
<exclude name="Squiz.Operators.ComparisonOperatorUsage" />
158-
<exclude name="Squiz.PHP.CommentedOutCode" />
159-
<exclude name="Squiz.PHP.DisallowBooleanStatement" />
160-
<exclude name="Squiz.PHP.DisallowComparisonAssignment" />
161-
<exclude name="Squiz.PHP.DisallowInlineIf" />
162-
<exclude name="Squiz.PHP.EmbeddedPhp" />
163-
<exclude name="Squiz.Strings.ConcatenationSpacing" />
164-
<exclude name="Squiz.WhiteSpace" />
165-
</rule>
166-
167-
<rule ref="Squiz.Commenting.EmptyCatchComment" />
168-
169-
<!-- exclude some checks for the examples-->
170-
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
171-
<exclude-pattern>examples</exclude-pattern>
172-
</rule>
173-
174-
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
175-
<exclude-pattern>examples</exclude-pattern>
189+
<rule ref="Squiz.Strings.ConcatenationSpacing">
190+
<properties>
191+
<property name="ignoreNewlines" value="true" />
192+
</properties>
176193
</rule>
177194

178-
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
179-
<exclude-pattern>examples</exclude-pattern>
195+
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
196+
<properties>
197+
<property name="ignoreNewlines" value="true" />
198+
</properties>
180199
</rule>
181200

182-
<rule ref="Squiz.Classes.ClassFileName.NoMatch">
183-
<exclude-pattern>examples</exclude-pattern>
201+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
202+
<properties>
203+
<property name="ignoreNewlines" value="true" />
204+
</properties>
184205
</rule>
185206

186-
<rule ref="Squiz.PHP.DiscouragedFunctions.Discouraged">
187-
<exclude-pattern>examples</exclude-pattern>
207+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
208+
<properties>
209+
<property name="ignoreBlankLines" value="true" />
210+
</properties>
188211
</rule>
189212

190213
</ruleset>

src/Core/PAR.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @copyright 2024 smiley
88
* @license MIT
99
*/
10+
declare(strict_types=1);
1011

1112
namespace chillerlan\OAuth\Core;
1213

src/Core/PKCE.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @copyright 2024 smiley
88
* @license MIT
99
*/
10+
declare(strict_types=1);
1011

1112
namespace chillerlan\OAuth\Core;
1213

src/Core/UserInfo.php

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @copyright 2024 smiley
88
* @license MIT
99
*/
10+
declare(strict_types=1);
1011

1112
namespace chillerlan\OAuth\Core;
1213

src/Providers/AzureActiveDirectory.php

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ abstract class AzureActiveDirectory extends OAuth2Provider implements CSRFToken{
3030
protected string $authorizationURL = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize';
3131
protected string $accessTokenURL = 'https://login.microsoftonline.com/common/oauth2/v2.0/token';
3232
protected string|null $userRevokeURL = 'https://account.live.com/consent/Manage';
33+
// phpcs:ignore
3334
protected string|null $applicationURL = 'https://aad.portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps';
3435

3536
}

src/Providers/Patreon.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ public function me():AuthenticatedUser{
6363

6464
if(in_array($this::SCOPE_V2_IDENTITY, $token->scopes)){
6565
$endpoint = '/v2/identity';
66-
$params = ['fields[user]' => 'about,created,email,first_name,full_name,image_url,last_name,social_connections,thumb_url,url,vanity'];
66+
$params = [
67+
'fields[user]' => 'about,created,email,first_name,full_name,image_url,'.
68+
'last_name,social_connections,thumb_url,url,vanity'
69+
];
6770
}
6871
elseif(in_array($this::SCOPE_V1_USERS, $token->scopes)){
6972
$endpoint = '/api/current_user';

0 commit comments

Comments
 (0)