1.2.680. Method Has Fluent Interface¶
Mark a method when it only returns $this.
Fluent interfaces allows for chaining methods calls. This implies that $this is always returned, so that the next method call is done on the same object.
<?php
$object = new foo();
$object->this()
->is()
->a()
->fluent()
->interface();
class foo {
function this() {
// doSomething
return $this;
}
function is() {
// doSomethingElse
return $this;
}
/// Etc. for a(), fluent(), interface()...
}
?>
See also Fluent Interfaces in PHP and Fluent Interfaces are Evil.
1.2.680.1. Connex PHP features¶
1.2.680.1.1. Specs¶
Short name |
Functions/HasFluentInterface |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
|
Time To Fix |
|
Precision |
Very high |
Available in |