Closed norkunas closed 1 year ago
hello,
I think what you should do is to configure the instantiator as following:
// EntityWithConstructorUnionTypeFactory
public function initialize(): self
{
return $this->instantiateWith(
(new Instantiator())->alwaysForceProperties()->withoutConstructor()
);
}
this way, your constructor won't be called and you will be able to rely on the properties' name
But my point that the constructor logic should run,i dont want to duplicate it :)
If you set the $fieldX
nullable by defaults, this logic is not needed anymore 😇
Lib should not force to change entities imho:)
Anyway, I think this has been fixed by #457 which is not released yet. I'll check before releasing
ok I can confirm it works on the main branch... see https://github.com/zenstruck/foundry/pull/466
I'll release it today
thank you :)
version 1.33.0 has just been release, is the issue fixed?
version 1.33.0 has just been release, is the issue fixed?
yes :raised_hands:
For example I have this entity:
and three foundry factories for all these entities. Now in the
EntityWithConstructorUnionType
factory i declare:And an error is thrown:
If i rename from
object
totype1
ingetDefaults()
then other error is thrown: