I was looking at the wiki page about the code templates
https://wiki.app.infra.gs.xtrav.de/doku.php?id=root:traso:entwicklung:codestyle:general
I have noticed that the code for
Code PHP Setter Method
has a little change in comparison to the original template in the
PHPstorm
public
${STATIC} function set${NAME}($${PARAM_NAME})
{
#if (${STATIC}
== "static")
self::$${FIELD_NAME} = $${PARAM_NAME};
#else
$this->${FIELD_NAME}
= $${PARAM_NAME};
return
$this;
#end
}
If you are returning $this, it is called FLUENT setter....so that
you can chain setters on the object.
This is already a part of the previous template in the wiki page
Code PHP Fluent Setter Method
public function
set${NAME}($${PARAM_NAME})
{
$this->${FIELD_NAME} = $${PARAM_NAME};
return
$this;
}
So In my opinion, no need to return $this from a
method which is not made with a FLUENT template, because
both normal and fluent templates returns $this.
So what is the point of having the option to chose between
normal and fluent setter template?
In the screenshot below, we see that we have an option to
choose fluent or normal setter.
Greetings,
Dragan
