-
-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPCS 3.4.0: use File::getMethodProperties() / 'has_body' #1514
Comments
I can confirm that for the The spacing issue in the following code does not get reported: // Abstract or stub without body:
class Foo {
abstract function Bar( $param);
// ------------------------------^
}
interface Foo {
function Bar( $param);
// ---------------------^
}
$bar = fn( $param) => $param;
// --------------^ As far as I can tell, the reason for this, is that in Having something like /**
* @param int $stackPtr The index of the token in the stack. This must point to
* either a T_FUNCTION, T_CLOSURE, T_USE, or T_FN token.
*
* @since 3.0.0
*
* @return bool Whether the token is a function call with a body.
*/
protected function is_method_with_body( $stackPtr ) {
try {
$method_parameters = $this->phpcsFile->getMethodParameters( $stackPtr );
return $method_parameters['has_body'] === true;
} catch( \PHP_CodeSniffer\Exceptions\RuntimeException $e ) {
return false;
}
} |
@vdwijngaert Your issue sounds more closely related to #1101... |
WPCS 3.0 will have PHPCS 3.7.2 as the minimum. |
I think we can actually close this issue. I just double-checked, but WPCS 3.0.0 won't contain any sniffs which would benefit from that key. |
Rationale
WPCS includes a number of sniffs which examine function declarations.
Functions can be declared with or without body:
In PHPCS 3.4.0, the output of the upstream
File::getMethodProperties()
method has been enhanced to contain a'has_body'
array key.It should be examined if existing code in WPCS:
References
Action Checklist
Once WPCS ups the minimum required PHPCS version to 3.4.0:
T_FUNCTION
token/ which deal with function declarations to see:has_body
key in the output from theFile::getMethodProperties()
method.The text was updated successfully, but these errors were encountered: