1.2.756. MustUseResult¶
The MustUseRresult
attribute means that the returned value of the method must be used. It should at least be collected.
<?php
class x {
#[MustUseResult]
function mustbeused() : int {
return 1;
}
function mustnotbeused() : int {
return 1;
}
}
$x = new x;
// Missing usage
$x->mustbeused();
// Return value is collected, for later usage
$c = $x->mustbeused();
?>
See also https://github.com/DaveLiddament/php-language-extensions?tab=readme-ov-file#mustuseresult.
1.2.756.1. Connex PHP features¶
1.2.756.1.1. Specs¶
Short name |
Attributes/MustUseResult |
Rulesets |
|
Exakat since |
2.6.8 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Related rule |
|
Available in |