Closed
Description
Symfony version(s) affected: 4.1.8
Description
#28966 fixing an issue where a model has 2 properties, the 2nd property name being the plural form of the first.
The fix introduced a change in behaviour when a model has a collection property, that has a setter and an adder+remover defined.
class Foo
{
private $invoices = [];
public function setInvoices(array $invoices): void
{
//...
}
public function addInvoice(Invoice $invoice): void
{
//...
}
public function removeInvoice(Invoice $item): void
{
//...
}
}
If setting the invoices collection:
- before [PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist #28966, the adder/remover is used over the setter.
- after [PropertyAccessor] Fix unable to write to singular property using setter while plural adder/remover exist #28966, the setter is used over the added/remover.
It could be said that if your model is depending on an order here, your model probably has a bug.
In fact, the change of behaviour did indeed highlighted a bug in my model, so I'm grateful for that!
Regardless, is this an intended, acceptable behaviour change for collection properties?