You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In files where I am using Closures with use statements and return typehints, I am getting this error:
1 | ERROR | An error occurred during processing; checking has been aborted. The error message was: Undefined index: parenthesis_owner in||<project>/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php on line 349 (Internal.Exception)
The issue seems to be if there is not a space between the close parenthesis of the use statement and the colon for the return type declaration.
Minimal Code Snippet
// This version fails$matching_options = array_filter(
$imported_options,
function ( $option ) use ( $option_id ): bool {
return$option['id'] === $option_id;
}
);
// This version is OK$matching_options = array_filter(
$imported_options,
function ( $option ) use ( $option_id ) : bool {
return$option['id'] === $option_id;
}
);
Error Code
N/A
Environment
Question
Answer
PHP version
7.3.6
PHP_CodeSniffer version
3.5.2
WPCS version
2.2.0
WPCS install type
Composer project local
IDE (if relevant)
PhpStorm 2019.2.5
Additional Context (optional)
N/A
Tested Against develop branch?
I have verified the issue still exists in the develop branch of WPCS.
Reviewing code diff since last release, this file is unchanged, so I didn't test against the develop branch but can if need be
The text was updated successfully, but these errors were encountered:
The short summary is that functions and closures were added to the ControlStructureSpacing sniff, but shouldn't have been. They need their own sniff(s).
Updated the issue description a bit since PhpStorm started highlighting some lines after updating all the tooling. Through PhpStorm's inspector, somehow I worked out that the error only exists on a Closure that has a use statement and that the undefined index error goes away if you put a space between the closing parenthesis and the colon. Normal functions and class methods, as well as Closures without a use, don't error if there is no space in between. So, hopefully that helps narrow down a smaller bugfix without needing any larger refactoring.
Bug Description
In files where I am using Closures with use statements and return typehints, I am getting this error:
The issue seems to be if there is not a space between the close parenthesis of the
use
statement and the colon for the return type declaration.Minimal Code Snippet
Error Code
N/A
Environment
Additional Context (optional)
N/A
Tested Against
develop
branch?develop
branch of WPCS.Reviewing code diff since last release, this file is unchanged, so I didn't test against the develop branch but can if need be
The text was updated successfully, but these errors were encountered: