1.2.682. Method Is Not For Fluent Interface¶
Mark a method when it contains at least one return that doesn’t return $this. Such method cannot be used for fluent interface, which always require the current object to be returned.
Null is not accepted here: it would break the execution of the method call chains if it was returned.
<?php
class x {
// fluent interface : $this is chainable
function foo() {
return $this;
}
// Not for fluent interface : the method may return something else
function goo($a) {
if ($a == true) {
return $this;
} else {
return 3;
}
}
}
?>
1.2.682.1. Connex PHP features¶
1.2.682.1.1. Specs¶
Short name |
Functions/HasNotFluentInterface |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
|
Time To Fix |
|
Precision |
Very high |
Available in |