DDC-1518: Method chaining in Setters of generated entity classes #1903

Open
opened 2026-01-22 13:30:22 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Dec 2, 2011).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user naitsirch:

Hi.
It would be nice if the set-methods of the generated entity classes would return the entity instance itself, so that method chaining is possible.
Example:

$user = new User();
$user->setUsername()
     ->setFirstname()
     ->setEmail();

In PHP 5.4 we can do even more nicer:

$user = new User()
     ->setUsername()
     ->setFirstname()
     ->setEmail();

If this is not wanted by everyone, the console tool could get a new argument to define if method chaining should be used or not.

Implementation of this improvement would be very nice. Thanks.

Originally created by @doctrinebot on GitHub (Dec 2, 2011). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user naitsirch: Hi. It would be nice if the set-methods of the generated entity classes would return the entity instance itself, so that method chaining is possible. Example: ``` $user = new User(); $user->setUsername() ->setFirstname() ->setEmail(); ``` In PHP 5.4 we can do even more nicer: ``` $user = new User() ->setUsername() ->setFirstname() ->setEmail(); ``` If this is not wanted by everyone, the console tool could get a new argument to define if method chaining should be used or not. Implementation of this improvement would be very nice. Thanks.
admin added the Improvement label 2026-01-22 13:30:22 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1903