Skip to content

Commit 7cd46be

Browse files
committed
PHP 8 | ControlStructureSpacing: bug fix - $data should be an array
The `$data` parameter of the `$phpcsFile->add[Fixable]Error|Warning()` methods is expected to be an array, not a string. Without this fix, PHP 8 will throw and (uncaught) `TypeError: vsprintf(): Argument #2 ($args) must be of type array, string given`.
1 parent 08ef3d6 commit 7cd46be

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function process_token( $stackPtr ) {
209209
$error,
210210
$stackPtr,
211211
'SpaceBeforeFunctionOpenParenthesis',
212-
$this->tokens[ ( $function_name_ptr + 1 ) ]['content']
212+
array( $this->tokens[ ( $function_name_ptr + 1 ) ]['content'] )
213213
);
214214

215215
if ( true === $fix ) {
@@ -282,7 +282,7 @@ public function process_token( $stackPtr ) {
282282
$error,
283283
$stackPtr,
284284
'ExtraSpaceBeforeOpenParenthesis',
285-
$this->tokens[ ( $stackPtr + 1 ) ]['content']
285+
array( $this->tokens[ ( $stackPtr + 1 ) ]['content'] )
286286
);
287287

288288
if ( true === $fix ) {
@@ -310,7 +310,7 @@ public function process_token( $stackPtr ) {
310310
$error,
311311
$stackPtr,
312312
'ExtraSpaceAfterOpenParenthesis',
313-
$this->tokens[ ( $parenthesisOpener + 1 ) ]['content']
313+
array( $this->tokens[ ( $parenthesisOpener + 1 ) ]['content'] )
314314
);
315315

316316
if ( true === $fix ) {
@@ -341,7 +341,7 @@ public function process_token( $stackPtr ) {
341341
$error,
342342
$stackPtr,
343343
'ExtraSpaceBeforeCloseParenthesis',
344-
$this->tokens[ ( $parenthesisCloser - 1 ) ]['content']
344+
array( $this->tokens[ ( $parenthesisCloser - 1 ) ]['content'] )
345345
);
346346

347347
if ( true === $fix ) {
@@ -399,7 +399,7 @@ public function process_token( $stackPtr ) {
399399
$error,
400400
$stackPtr,
401401
'ExtraSpaceAfterCloseParenthesis',
402-
$this->tokens[ ( $parenthesisCloser + 1 ) ]['content']
402+
array( $this->tokens[ ( $parenthesisCloser + 1 ) ]['content'] )
403403
);
404404

405405
if ( true === $fix ) {

0 commit comments

Comments
 (0)