Why method chaining is allowed by default in generated entities? #5405

Closed
opened 2026-01-22 15:06:52 +01:00 by admin · 2 comments
Owner

Originally created by @Kwadz on GitHub (Feb 5, 2017).

Originally assigned to: @Ocramius on GitHub.

Is there a good reason to allow method chaining by default in generated entities?

class Product
{
    public function setName($name)
    {
        $this->name = $name;

        return $this; // Why this is by default?
    }
}

I think this feature should only be present when it is needed. I there is no reason to have it by default, I'd like to make it configurable. What do you think about that?

Originally created by @Kwadz on GitHub (Feb 5, 2017). Originally assigned to: @Ocramius on GitHub. Is there a good reason to allow method chaining by default in generated entities? ``` class Product { public function setName($name) { $this->name = $name; return $this; // Why this is by default? } } ``` I think this feature should only be present when it is needed. I there is no reason to have it by default, I'd like to make it configurable. What do you think about that?
admin added the ImprovementWon't FixQuestion labels 2026-01-22 15:06:52 +01:00
admin closed this issue 2026-01-22 15:06:52 +01:00
Author
Owner

@Ocramius commented on GitHub (Feb 5, 2017):

@Kwadz I would rather just drop it: it's a bad practice, but it seems like many rely on it (yes, we tried dropping it before).

Closing here - possible change for 3.x, but we'd split the entity generator out anyway, so I'm closing this one as won't fix

@Ocramius commented on GitHub (Feb 5, 2017): @Kwadz I would rather just drop it: it's a bad practice, but it seems like many rely on it (yes, we tried dropping it before). Closing here - possible change for 3.x, but we'd split the entity generator out anyway, so I'm closing this one as `won't fix`
Author
Owner

@Kwadz commented on GitHub (Feb 5, 2017):

Sorry, I've just realized:

but it seems like many rely on it (yes, we tried dropping it before).

@Kwadz commented on GitHub (Feb 5, 2017): Sorry, I've just realized: >but it seems like many rely on it (yes, we tried dropping it before).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5405