-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: fix doctrine collection with union/intersection type #847
fix: fix doctrine collection with union/intersection type #847
Conversation
Hi @mdeboer thanks for this fix! could you please add a non regression test, please? Don't hesitate if you need some hints about the testsuite |
3bad1cd
to
1c3c024
Compare
@nikophil I am fairly new with the project itself and I see that the I don't have that much time to spend unfortunately, but I can add a few basic unit tests to that cover my changes? |
could you please provide an example of failing code here please? so I can understand the problem better, I'll write the test myself |
Yeah I'm writing some basic unit tests for the But for instance, hydrating this would work in v2.3.1 but fails in v2.3.2+: <?php
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Selectable;
class Foo {
public Collection&Selectable $foo;
__construct() {
$this->foo = new ArrayCollection();
}
} This is because |
ok thanks! If you have some time to write a unit test for the hydrator, that's super nice! I'll create an integration test anyway.
yeah that's totally true. I wish I could use component type info for this, this would have prevented this I guess |
@nikophil I have added some unit tests for the |
Pretty nice! could you rebase on Also, I might make some changes on your PR before merging |
@nikophil I already based it on |
61ae401
to
179bdcb
Compare
179bdcb
to
4aae90b
Compare
hi @mdeboer your fix is released https://github.com/zenstruck/foundry/releases/tag/v2.3.8 |
Thank you so much! Appreciate the quick response 😁 Keep up the good work! |
* 2.3.x: bot: fix cs [skip ci] fix: handle "inverse one to one" without "placeholder" solution (zenstruck#855) bot: fix cs [skip ci] feat: add force() helper (zenstruck#854) chore: add support for doctrine/persistence 4 (zenstruck#852) fix: fix doctrine collection with union/intersection type (zenstruck#847) bot: fix cs [skip ci] fix: bug with factory collectin of persistent factory in unit test (zenstruck#842) fix: use Doctrine metadata event when persist is disabled (zenstruck#841) minor: add parameter "withAutoRefresh" to unproxy() function (zenstruck#840) chore: upgrade also dama when upgrading phpunit version (zenstruck#839) bot: fix cs [skip ci] changelog: update [skip ci] fix: can call ->create() in after persist callback (zenstruck#833)
* fix: can call ->create() in after persist callback (#833) * changelog: update [skip ci] * bot: fix cs [skip ci] * chore: upgrade also dama when upgrading phpunit version (#839) * minor: add parameter "withAutoRefresh" to unproxy() function (#840) * fix: use Doctrine metadata event when persist is disabled (#841) * fix: bug with factory collectin of persistent factory in unit test (#842) * bot: fix cs [skip ci] * fix: fix doctrine collection with union/intersection type (#847) * fix: fix hydrator with doctrine collections using intersection types * feat: add unit tests for hydrator * test: add functional test for union type --------- Co-authored-by: Nicolas PHILIPPE <[email protected]> * chore: add support for doctrine/persistence 4 (#852) * feat: add force() helper (#854) * bot: fix cs [skip ci] * fix: handle "inverse one to one" without "placeholder" solution (#855) * fix: one to one no more uses placeholder * fix: use different error message if types are missing * bot: fix cs [skip ci] * changelog: update --------- Co-authored-by: nikophil <[email protected]> Co-authored-by: Maarten de Boer <[email protected]> Co-authored-by: chris <[email protected]>
This PR fixes an issue introduced in v2.3.2 where hydrating doctrine collections with a union or intersection type failed. These types were not recognized as doctrine collections and therefore they were assigned as
array
instead ofArrayCollection
.