Closed ThomasLandauer closed 4 years ago
Hi @ThomasLandauer I personally don't like setters to return values because in my opinion they should only set something. Personally I would only use fluent language for things like builders, not for setting properties. I know there is no right or wrong, but it's more a matter of personal preference and I think this is cleaner. Thanks anyway.
Doctrine Maker Bundle https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html creates all setters "fluently", that's why I'm used to it, and I figured this would be the current best practice.
I see both on a regular basis (and I have used fluent interface in earlier project) but there is no generally used or agreed best practice or standard so you are free to make your own decision. Some people like the pureness of having void setters and others like the flexibility of the fluent interface.
Wouldn't it be easier if all setters would return
$this
, so that you can do this: