Skip to content
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

Extract AssociationMapping in its own DTO #10613

Merged
merged 1 commit into from Apr 13, 2023

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented Apr 3, 2023

No description provided.

@greg0ire
Copy link
Member Author

greg0ire commented Apr 3, 2023

I've tried splitting out JoinColumnMapping in a separate PR, but it was too hard. Sorry for the big PR 😓

@greg0ire

This comment was marked as resolved.

lib/Doctrine/ORM/Cache/DefaultEntityHydrator.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/AssociationMapping.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/AssociationMapping.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/AssociationMapping.php Outdated Show resolved Hide resolved
'isCascadeRefresh' => $this->isCascadeRefresh(),
'isCascadeDetach' => $this->isCascadeDetach(),
'isCascadeMerge' => $this->isCascadeMerge(),
default => $this->$offset,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure the property exists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we? If we don't, we'll get the same behavior when using $mapping['offset'] as when using $mapping->offset, and IMO we want that, because it means one less difference when migrating to the object API.

>>> $mapping['foo'];
<warning>PHP Warning:  Undefined property: Doctrine\Tests\ORM\Mapping\MyAssociationMapping::$foo in /home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php on line 213</warning>
=> null

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, this is just a warning and for setter part, it's even just a deprecation on PHP 8.2. Being more strict allows us to spot places where we forgot to add a property.

If accessing dynamic properties is what we want here, we should opt-in via #[AllowDynamicProperties].

I feel like we've had that discussion already. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we very much did 😆 I can add an exception if you insist. Will \InvalidArgumentException suit you, since this is probably not meant to be caught? If not, please let me know what type you want exactly, to avoid more back and forth.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marking as draft because adding an exception shows there are cases where I fetch properties that do not exist:

1) Doctrine\Tests\ORM\Functional\CompositePrimaryKeyWithAssociationsTest::testFindByAbleToGetCompositeEntitiesWithMixedTypeIdentifiers
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/CompositePrimaryKeyWithAssociationsTest.php:40

2) Doctrine\Tests\ORM\Functional\SecondLevelCacheCompositePrimaryKeyWithAssociationsTest::testFindByReturnsCachedEntity
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:277
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheCompositePrimaryKeyWithAssociationsTest.php:47

3) Doctrine\Tests\ORM\Functional\SecondLevelCacheManyToOneTest::testPutAndLoadNonCacheableManyToOne
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:277
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php:195

4) Doctrine\Tests\ORM\Functional\SecondLevelCacheManyToOneTest::testPutAndLoadNonCacheableCompositeManyToOne
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:277
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php:233

5) Doctrine\Tests\ORM\Functional\SecondLevelCacheOneToManyTest::testPutAndLoadNonCacheableOneToMany
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:277
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php:406

6) Doctrine\Tests\ORM\Functional\SecondLevelCacheOneToOneTest::testPutAndLoadNonCacheableOneToOne
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Cache/Persister/Entity/AbstractEntityPersister.php:277
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToOneTest.php:267

7) Doctrine\Tests\ORM\Functional\Ticket\DDC117Test::testReferencesToForeignKeyEntities
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\ManyToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:276

8) Doctrine\Tests\ORM\Functional\Ticket\DDC117Test::testLoadManyToManyCollectionOfForeignKeyEntities
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\ManyToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:391
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:301

9) Doctrine\Tests\ORM\Functional\Ticket\DDC117Test::testClearManyToManyCollectionOfForeignKeyEntities
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\ManyToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:391
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:318

10) Doctrine\Tests\ORM\Functional\Ticket\DDC117Test::testLoadInverseManyToManyCollection
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\ManyToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:391
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:332

11) Doctrine\Tests\ORM\Functional\Ticket\DDC117Test::testLoadOneToManyOfSourceEntityWithAssociationIdentifier
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\ManyToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:391
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC117Test.php:357

12) Doctrine\Tests\ORM\Functional\Ticket\DDC2252Test::testIssue
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\ManyToManyOwningSideMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:416
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:57
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:401
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php:75
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2252Test.php:50

13) Doctrine\Tests\ORM\Functional\Ticket\GH7062Test::testEntityWithAssociationKeyIdentityCanBeUpdated
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:661
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:686
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:236
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:1021
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:384
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php:58
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7062Test.php:44

14) Doctrine\Tests\ORM\Persisters\BasicEntityPersisterCompositeTypeParametersTest::testExpandParametersWillExpandCompositeEntityKeys
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:1844
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:1777
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php:38

15) Doctrine\Tests\ORM\Persisters\BasicEntityPersisterCompositeTypeParametersTest::testExpandCriteriaParametersWillExpandCompositeEntityKeys
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\OneToManyAssociationMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:1844
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:858
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Persisters/BasicEntityPersisterCompositeTypeParametersTest.php:52

16) Doctrine\Tests\ORM\Persisters\ManyToManyPersisterTest::testDeleteManyToManyCollection
InvalidArgumentException: Unknown property joinColumns on class Doctrine\ORM\Mapping\ManyToManyOwningSideMapping

/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Mapping/AssociationMapping.php:220
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Utility/PersisterHelper.php:73
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:416
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/Persisters/Collection/ManyToManyPersister.php:57
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/UnitOfWork.php:401
/home/gregoire/dev/doctrine-orm/lib/Doctrine/ORM/EntityManager.php:267
/home/gregoire/dev/doctrine-orm/tests/Doctrine/Tests/ORM/Persisters/ManyToManyPersisterTest.php:45

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, as well as a similar condition below. The warnings/exceptions have disappear, please advise on

// iterate over to-one association mappings
foreach ($class->associationMappings as $assoc) {
if (! isset($assoc['joinColumns'])) {
continue;
}
, I'm convinced having that exception, even if that's temporary may be useful now 😆

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will \InvalidArgumentException suit you, since this is probably not meant to be caught?

I tried hard to resist my impulse to nit-pick here, but… … …

OutOfBoundsException was made for this.

Sorry. 😓

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, actually OutOfRangeException because the caller could have known in advance that the key is invalid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, the exception is just temporary. Any of these three would do.

🏃🏻‍♂️💨

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OutOfRangeException it is then… indeed, it looks perfectly suited to this 👍

lib/Doctrine/ORM/Mapping/JoinColumnMapping.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/ToOneAssociationMapping.php Outdated Show resolved Hide resolved
@greg0ire greg0ire force-pushed the association-mapping branch 2 times, most recently from 9614e46 to 5b8629c Compare April 4, 2023 07:28
@greg0ire greg0ire requested a review from derrabus April 4, 2023 07:34
@greg0ire greg0ire marked this pull request as draft April 4, 2023 08:33
@greg0ire greg0ire force-pushed the association-mapping branch 2 times, most recently from 3198a1a to 67fcf67 Compare April 4, 2023 09:12
@greg0ire greg0ire marked this pull request as ready for review April 4, 2023 09:28
Copy link
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those instanceof checks of mappings are reoccurring multiple times. I'd prefer to have them in their own mapping-methods for simplicity.

$value = JoinTableMapping::fromMappingArray($value);
}

$this->$offset = $value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OutOfRangeException if property does not exist.

@greg0ire
Copy link
Member Author

greg0ire commented Apr 5, 2023

Those instanceof checks of mappings are reoccurring multiple times. I'd prefer to have them in their own mapping-methods for simplicity.

I just pushed a new version where I introduce more of those methods. There are still instanceof checks that remain, some of which might disappear when phpstan/phpstan#8904 gets fixed. Other are checks inside tests, I assumed you didn't mean those ones.

lib/Doctrine/ORM/Mapping/AssociationMapping.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/AssociationMapping.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/Mapping/JoinTableMapping.php Outdated Show resolved Hide resolved
Copy link
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 but there's an unaddressed comment #10613 (comment)

@greg0ire
Copy link
Member Author

@SenseException @derrabus I actually addressed that comment by introducing a few lines of code above, which might explain why that diff is not marked as outdated.

@greg0ire greg0ire added this to the 3.0.0 milestone Apr 12, 2023
@greg0ire greg0ire dismissed derrabus’s stale review April 13, 2023 17:32

requestd change has been addressed.

@greg0ire greg0ire merged commit eaac5cd into doctrine:3.0.x Apr 13, 2023
37 checks passed
@greg0ire greg0ire deleted the association-mapping branch April 13, 2023 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants