-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist #28966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist #28966
Conversation
…ter while plural adder/remover exist
@nicolas-grekas This bug exists in 4.1 and master, is this PR going to be merged in there as well? |
@karser yes: we regularly merge lower branches into upper ones. |
Thank you @karser. |
…y using setter while plural adder/remover exist (karser) This PR was merged into the 3.4 branch. Discussion ---------- [PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28961 | License | MIT Please take a look at the tests I added - they describe the issue. It has to do with the priorities: `findAdderAndRemover('User', 'email')` is called earlier than `$this->isMethodAccessible('User', 'setEmail', 1)` Commits ------- 8238f16 [PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist
I think we have a problem here which has caused a regression, or at least a change in behaviour. If you have a collection property which has a setter, an adder and a remover: class Foo
{
private $invoices = [];
public function setInvoices(array $invoices): void
{
//...
}
public function addInvoice(Invoice $invoice): void
{
//...
}
public function removeInvoice(Invoice $item): void
{
//...
}
} prior to this change, the adder/remover were used over the setter, but with this change, the setter is prioritized over the adder/remover. Yes, Is this an intended, acceptable consequence? |
Please take a look at the tests I added - they describe the issue. It has to do with the priorities:
findAdderAndRemover('User', 'email')
is called earlier than$this->isMethodAccessible('User', 'setEmail', 1)