New in Symfony 4.3: Configuring services with immutable setters

A common need in some Symfony applications is to use immutable services while
still using traits for composing their optional features. Although the Symfony
service container supports setter injection, they have some drawbacks (e.g.
setters can be called more than just at the time of construction so you cannot
be sure the dependency is not replaced during the lifetime of the object).

A pattern to solve this problem are "wither methods". These methods typically
use the with word as the prefix of their names (e.g. withPropertyName())
and they return a copy of an instance of an immutable class with only that one
property changed:

returning "self" is not enough: this would be inaccurate for child classes. The correct return type would be "static" - but that's not allowed in the language, that's why it has to be in the annotation.