Feature #72174
closedFluent setter for AbstractDomainObject->setPid()
0%
Description
public function setPid($pid) {...}
should not return void but $this to use it fluently.
Updated by Mathias Brodala over 8 years ago
- Status changed from New to Needs Feedback
Why exactly? There is no domain model/object in TYPO3 which spurs a fluent interface, why should this setter be an exception?
Updated by Frank Nägler over 8 years ago
If we change this we have to change the DomainObjectInterface too, which is a breaking change.
Updated by Matthias Schröder over 8 years ago
This one I came across several times when creating a new domain model object.
I think it would be nice, if all setters implemented the fluent interface (if possible), because it is much ore convenient and improves code readability.
Example:
$event = GeneralUtility::makeInstance(Event::class) $event->setPid(101); $event ->setTeaserText($faker->text(100)) ->setCategory(rand(1, 3)) ->setVenue($faker->text(15)) ->setAddress($faker->address) ... ;
Updated by Alexander Opitz about 8 years ago
- Status changed from Needs Feedback to New
- Target version set to Candidate for Major Version
Updated by Benni Mack over 3 years ago
- Status changed from New to Rejected
I see your point here, but considering adding this as "breaking" change for a fluent API seems a bit much. Also, personally, I'd recommend using Factories or the constructor to set up the object, as this brings the code that uses the domain model in a defined state. See latest PHP8 additions, which directly point to such features.
Sorry (also for the late reply).