Drupal's documentation standards state: "Use @throws if your method can throw an exception, followed by the name of the exception class."

The purpose of this issue is to create a sniff that will report when a docblock is missing the required @throws directive if the function/method throws an exception.

CommentFileSizeAuthor
#3 1821592-3-missing-throws.patch1.83 KBLars Toomre
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lars Toomre’s picture

I created #1821712: Add @throws directive to docblocks as needed so that core files can be correct while this sniff is being worked on.

Lars Toomre’s picture

I also posted a patch to #1821712: Add @throws directive to docblocks as needed that corrects this issue in about thirty files. There are approximately 300 files in core that need to be reviewed and possibly corrected for this issue.

Lars Toomre’s picture

Status: Active » Needs work
FileSize
1.83 KB

Here is a work-in-progress patch. I have yet to figure out retrieve the function code that goes along with a docblock. I am a PHP_CodeSniffer newbie and would appreciate some guidance.

klausi’s picture

Component: Code Sniffer » Coder Sniffer
Issue summary: View changes
Status: Needs work » Closed (won't fix)

Coder 7.x is frozen now and will not receive updates. Coder 8.x-2.x can be used to check code for any Drupal version, Coder 8.x-2.x also supports the phpcbf command to automatically fix conding standard errors. Please check if this issue is still relevant and reopen against that version if necessary.