Skip to content
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

Squiz.Commenting.FunctionCommentThrowTag.WrongNumber not triggered if no throw statement in function body #3899

Open
smileBeda opened this issue Oct 12, 2023 · 0 comments

Comments

@smileBeda
Copy link

Bug Description

Squiz.Commenting.FunctionCommentThrowTag.WrongNumber is only triggered if at least one throw is present in the function body, and a wrong number of @throws docbloc statements is present.
It is not triggered, if a wrong number of @throws docbloc statements is present but no throw statement is present in the function body.

Minimal Code Snippet

/**
 * Short Description
 *
 * @throws \AnException Comment.
 * @throws \AnotherException Comment.
 */
function check_it() {

	throw new \AnException(
		//do things
	);

}

Above will trigger the error.

However, if you do this, the error is not triggered:

/**
 * Short Description
 *
 * @throws \AnException Comment.
 * @throws \AnotherException Comment.
 */
function check_it() {

}

Error Code

Squiz.Commenting.FunctionCommentThrowTag.WrongNumber

Environment

PHP 8, WPCS 3.x, all dependencies updated to latest.
No dev.

@smileBeda smileBeda changed the title Squiz.Commenting.FunctionCommentThrowTag.WrongNumber not triggered if no throws statement in function body Squiz.Commenting.FunctionCommentThrowTag.WrongNumber not triggered if no throw statement in function body Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant