On IRC there was a question about @return None. The coding standards say not to have a @return element for functions that don't return but we don't do that in core. This fixes it.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 516254hookcron.patch | 2.3 KB | jhodgdon |
| #4 | drop_none_return.patch | 11.48 KB | drewish |
| drop_none_return.patch | 11.52 KB | drewish |
Comments
Comment #1
drewish commentedSpecifically the bit that says:
Comment #3
drewish commentedComment #4
drewish commentedremoving git's prefix.
Comment #5
dries commentedThis looks good to me. Tagging to be committed.
Comment #6
dries commentedCommitted to CVS HEAD. Thanks.
Comment #8
dave reidRe-opening this to accomplish before the release of 7.0. There are lots of added function with @return None that are silly.
Comment #9
jhodgdonI only see two incidents of @return None in Drupal 7 right now:
hook_cron() in modules/system/system.api.php
ajax_process_form() in includes/ajax.inc
These two should be fixed... But maybe my grep-fu is not as good as yours -- where else are you seeing them?
Comment #10
jhodgdonComment #11
jhodgdonActually, both of those function docs are terrible. The AJAX one, I'm not sure how to fix, and it may be on another issue...
Here's a patch for hook_cron() doc.
Comment #12
moshe weitzman commentedIMO, this is a bad standard. There is no way to distinguish missing docs from deliberate absence when using your IDE and so on.
Comment #13
jhodgdonWhat are you saying is a bad standard -- not having a @return if there is no return value? How long has that been our standard? Also, I think it's fairly standard across the software industry... such as:
http://java.sun.com/j2se/javadoc/writingdoccomments/#@return
Comment #14
aspilicious commentedI agree with jhodgdon in this case...
I never saw any standard saying you need to add "@return none" when there isn't any return value....
Comment #15
aspilicious commented#11 is rtbc
Comment #16
dries commentedTo Moshe's defense, Java is different in that you have to explicitly declare the return type. So when you see 'void' in the method signature, you know there is no return value. There is no such equivalent in PHP of course.
Comment #17
jhodgdon#11: 516254hookcron.patch queued for re-testing.
Comment #18
jhodgdon#11: 516254hookcron.patch queued for re-testing.
Comment #19
webchickI see moshe's point, but the idea of going around to every hook function, form submit/validate handler, testX() function, etc. and adding @return none fills me with absolute dread. Consistency is much easier to keep if we drop the @return on functions that don't return anything. And jhodgdon cites precedent, albeit from a strongly typed language.
Committed to HEAD.
If this isn't already documented in the coding standards, please do so.
Comment #20
jhodgdonIt's in the standards already.