Skip to content

Commit 2e79d09

Browse files
authored
Merge pull request #832 from WordPress/feature/update-to-wpcs-3.0
2 parents 7661070 + 7f933f2 commit 2e79d09

File tree

9 files changed

+30
-24
lines changed

9 files changed

+30
-24
lines changed

.github/workflows/cs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install PHP
2626
uses: shivammathur/setup-php@v2
2727
with:
28-
php-version: '7.4'
28+
php-version: 'latest'
2929
coverage: none
3030
tools: cs2pr
3131

.phpcs.xml.dist

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@
7171
<!-- Replaced by the Squiz version of the sniff which doesn't enforce whitespace around array index keys. -->
7272
<exclude name="WordPress.Arrays.ArrayKeySpacingRestrictions"/>
7373

74-
<!-- Disabled as the preference for this repo is no spaces on the inside of parentheses.
75-
Once WPCS 3.0.0 comes out, the opposite can be enforced via the
76-
NormalizedArrays.Arrays.ArrayBraceSpacing sniff from PHPCSExtra. -->
77-
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceAfterArrayOpener"/>
78-
<exclude name="WordPress.Arrays.ArrayDeclarationSpacing.NoSpaceBeforeArrayCloser"/>
79-
8074
<!-- Let spacing before a cast be determined by the operator/parentheses whitespace rule
8175
of the preceding character. -->
8276
<exclude name="WordPress.WhiteSpace.CastStructureSpacing"/>
@@ -86,7 +80,7 @@
8680
========================================================================== -->
8781
<exclude name="WordPress.PHP.YodaConditions"/>
8882
<!-- A while loop is the only valid control structure where an assignment can be justified. -->
89-
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>
83+
<exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>
9084

9185
<!-- ==========================================================================
9286
Miscellaneous other exclusions.
@@ -96,7 +90,7 @@
9690
<exclude name="WordPress.Files.FileName"/>
9791

9892
<!-- WPCS demands long arrays. We'll be using short arrays from now on. -->
99-
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
93+
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
10094

10195
<!-- Ignore WP specific sniffs as Requests is also used outside of a WP context. -->
10296
<exclude name="WordPress.WP"/>
@@ -133,6 +127,12 @@
133127
</properties>
134128
</rule>
135129

130+
<rule ref="NormalizedArrays.Arrays.ArrayBraceSpacing">
131+
<properties>
132+
<property name="spacesSingleLine" value="0"/>
133+
</properties>
134+
</rule>
135+
136136
<!-- Include replacement sniffs which enforce the opposite of WPCS for several excluded sniffs. -->
137137
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing">
138138
<exclude name="Squiz.WhiteSpace.ControlStructureSpacing.LineAfterClose"/>
@@ -173,7 +173,7 @@
173173
<!-- Allow error silencing only for a select group of functions. -->
174174
<rule ref="WordPress.PHP.NoSilencedErrors">
175175
<properties>
176-
<property name="custom_whitelist" type="array">
176+
<property name="customAllowedFunctionsList" type="array">
177177
<element value="gzdecode"/>
178178
<element value="gzinflate"/>
179179
<element value="gzuncompress"/>

composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@
4141
"ext-json": "*"
4242
},
4343
"require-dev": {
44-
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
4544
"php-parallel-lint/php-console-highlighter": "^1.0.0",
4645
"php-parallel-lint/php-parallel-lint": "^1.3.2",
4746
"phpcompatibility/php-compatibility": "^9.0",
4847
"requests/test-server": "dev-main",
4948
"roave/security-advisories": "dev-latest",
50-
"squizlabs/php_codesniffer": "^3.7.1",
51-
"wp-coding-standards/wpcs": "^2.0",
49+
"wp-coding-standards/wpcs": "^3.0",
5250
"yoast/phpunit-polyfills": "^2.0.0"
5351
},
5452
"suggest": {

library/Requests.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class Requests extends WpOrg\Requests\Requests {
5353
*
5454
* @codeCoverageIgnore
5555
*
56+
* @phpcs:disable Universal.NamingConventions.NoReservedKeywordParameterNames.classFound -- Deprecated, so not relevant to change.
57+
*
5658
* @param string $class Class name to load
5759
*/
5860
public static function autoloader($class) {

src/Session.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,13 @@ public function patch($url, $headers, $data = [], $options = []) {
227227
* @throws \WpOrg\Requests\Exception On invalid URLs (`nonhttp`)
228228
*/
229229
public function request($url, $headers = [], $data = [], $type = Requests::GET, $options = []) {
230-
$request = $this->merge_request(compact('url', 'headers', 'data', 'options'));
230+
$request = [
231+
'url' => $url,
232+
'headers' => $headers,
233+
'data' => $data,
234+
'options' => $options,
235+
];
236+
$request = $this->merge_request($request);
231237

232238
return Requests::request($request['url'], $request['headers'], $request['data'], $type, $request['options']);
233239
}

tests/Autoload/AutoloadTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static function ($errno, $errstr) {
6767
public function testAutoloadOfOldRequestsClassDoesNotThrowAFatalForFinalClass() {
6868
define('REQUESTS_SILENCE_PSR0_DEPRECATIONS', true);
6969

70-
$this->assertInstanceOf(FilteredIterator::class, new Requests_utility_filteredIterator([], static function() {}));
70+
$this->assertInstanceOf(FilteredIterator::class, new Requests_utility_filteredIterator([], static function () {}));
7171
}
7272

7373
/**

tests/Cookie/ConstructorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public function testAttributesAreNormalizedInDictionary() {
356356
*
357357
* @return array
358358
*/
359-
private function arrayUnshiftAssoc($base_array, $key, $value ) {
359+
private function arrayUnshiftAssoc($base_array, $key, $value) {
360360
$base_array = array_reverse($base_array, true);
361361
$base_array[$key] = $value;
362362
return array_reverse($base_array, true);

tests/Hooks/DispatchTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,48 +120,48 @@ public function testDispatchRespectsHookPriority() {
120120
// Register multiple callbacks for the same hook with a variation of priorities.
121121
$this->hooks->register(
122122
'hook_a',
123-
static function(&$text) {
123+
static function (&$text) {
124124
$text .= "no prio 0\n";
125125
}
126126
);
127127
$this->hooks->register(
128128
'hook_a',
129-
static function(&$text) {
129+
static function (&$text) {
130130
$text .= "prio 10-1\n";
131131
},
132132
10
133133
);
134134
$this->hooks->register(
135135
'hook_a',
136-
static function(&$text) {
136+
static function (&$text) {
137137
$text .= "prio -3\n";
138138
},
139139
-3
140140
);
141141
$this->hooks->register(
142142
'hook_a',
143-
static function(&$text) {
143+
static function (&$text) {
144144
$text .= "prio 5\n";
145145
},
146146
5
147147
);
148148
$this->hooks->register(
149149
'hook_a',
150-
static function(&$text) {
150+
static function (&$text) {
151151
$text .= "prio 2-1\n";
152152
},
153153
2
154154
);
155155
$this->hooks->register(
156156
'hook_a',
157-
static function(&$text) {
157+
static function (&$text) {
158158
$text .= "prio 2-2\n";
159159
},
160160
2
161161
);
162162
$this->hooks->register(
163163
'hook_a',
164-
static function(&$text) {
164+
static function (&$text) {
165165
$text .= "prio 10-2\n";
166166
},
167167
10

tests/Hooks/RegisterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function testRegister() {
183183
public function testRegisterClosureCallback() {
184184
$this->hooks->register(
185185
'hookname',
186-
static function($param) {
186+
static function () {
187187
return true;
188188
}
189189
);

0 commit comments

Comments
 (0)