Bug #11905
AlwaysReturnSniff does not recognize if/else constructs
| Status: | Accepted | Start date: | 2011-01-05 | |
|---|---|---|---|---|
| Priority: | Should have | Due date: | ||
| Assignee: | - | % Done: | 0% |
|
| Category: | Scope | Spent time: | - | |
| Target version: | 0.0.7 | |||
| Branch: | Tags: | Scope | ||
| Votes: | 0 |
Description
Running the sniffer on the attached file produces the following output:
12 | ERROR | This function must always have a return value 12 | ERROR | This function must always have a return value
The sniffer should recognize that in the following if/else construct, always a value is returned:
if (time() % 2) {
return TRUE;
} else {
return FALSE;
}
History
Updated by Stefano Kowalke over 2 years ago
- Category set to Scope
- Status changed from New to Accepted
- Target version set to 0.0.4
Updated by Andy Grunwald about 1 year ago
- Tags set to Scope
Updated by Andy Grunwald about 1 year ago
- Target version changed from 0.0.4 to 0.0.5
Updated by Stefano Kowalke 8 months ago
- Target version changed from 0.0.5 to 0.0.6
Updated by Arjen Hoekema 4 months ago
Same goes for using an anonymous function (closure) within a method/function with a "@return void":
/**
* @return void
*/
public function foo() {
$test = function() {
return 'bar';
}
}
Updated by Oliver Klee 4 months ago
Arjen Hoekema wrote:
Same goes for using an anonymous function (closure) within a method/function with a "@return void":
Arjen, I propose creating a new ticket for the problem with anonymous functions so this ticket keeps a (relatively) small scope (i.e., the quoted test code).
Care to create a ticket for the problem with the anonymous functions?
Updated by Stefano Kowalke 16 days ago
- Target version changed from 0.0.6 to 0.0.7