Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#3 | 1821592-3-missing-throws.patch | 1.83 KB | Lars Toomre |
Comments
Comment #1
Lars Toomre CreditAttribution: Lars Toomre commentedI created #1821712: Add @throws directive to docblocks as needed so that core files can be correct while this sniff is being worked on.
Comment #2
Lars Toomre CreditAttribution: Lars Toomre commentedI 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.
Comment #3
Lars Toomre CreditAttribution: Lars Toomre commentedHere 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.
Comment #4
klausiCoder 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.