Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #17055 [PEAR] @return required even for functions with no return statement
Submitted: 2010-02-02 23:28 UTC
From: hughitt1 Assigned: squiz
Status: Bogus Package: PHP_CodeSniffer (version 1.2.2)
PHP Version: 5.2.1 OS: Ubuntu 9.10
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 4 + 48 = ?

 
 [2010-02-02 23:28 UTC] hughitt1 (Keith Hughitt)
Description: ------------ When using the PEAR CS, phpcs complains "Missing @return tag in function comment" for functions which do no have a return statement. Although it is possible to do something like @return void, a better solution would be for phpcs to not require the comment for functions/methods where nothing is being returned.

Comments

 [2010-02-03 04:18 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Bogus -Assigned To: +Assigned To: squiz
You should be writing "@return void" to make it clear that your lack of return value is not a mistake. In the Squiz standard, PHPCS will actually confirm that any function claiming to return void is not returning a value anywhere, which is what I personally prefer. As this is simple a matter of opinion, I'm going to mark this report as bogus. If you'd like a specific exception added to the PEAR standard, please email the PEAR QA or dev list. If there is an exception already made in the standard that I haven't seen, just point it out for me and I'll reopen the bug.
 [2010-02-03 21:55 UTC] hughitt1 (Keith Hughitt)
Hi Greg, That's fine. I actually couldn't find anything in the actual CS about whether or not a return type should be specified. I could only find one discussion which suggested that at least as far as phpDocumentor is concerned, it's better to leave it out: http://stackoverflow.com/questions/2061550/phpdoc-return-void-necessary I think your point about explicitly marking the method as not having a return value is a good idea though. I'll do that. Thanks!