-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Accept both ClassMetadata
and ClassMetadataInfo
objects from the ORM
#2716
Accept both ClassMetadata
and ClassMetadataInfo
objects from the ORM
#2716
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2716 +/- ##
=======================================
Coverage 79.36% 79.36%
=======================================
Files 162 162
Lines 8457 8457
=======================================
Hits 6712 6712
Misses 1745 1745
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we are keeping ClassMetadataInfo
in case someone is extending it (unlikely, but 🤷♂️ ).
@@ -229,7 +230,7 @@ final public function setCacheItemPool(CacheItemPoolInterface $cacheItemPool): v | |||
*/ | |||
public function loadMetadataForObjectClass(ObjectManager $objectManager, $metadata) | |||
{ | |||
assert($metadata instanceof DocumentClassMetadata || $metadata instanceof EntityClassMetadata); | |||
assert($metadata instanceof DocumentClassMetadata || $metadata instanceof EntityClassMetadata || $metadata instanceof LegacyEntityClassMetadata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could add the dockblock @phpstan-assert ClassMetadata&(DocumentClassMetadata|EntityClassMetadata|LegacyEntityClassMetadata) $meta
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it, that assertion didn't change anything on its own. Removing the assert()
runtime call added errors, or trying @param ClassMetadata&(DocumentClassMetadata|EntityClassMetadata|LegacyEntityClassMetadata) $metadata
like is done elsewhere added more errors.
thanks @mbabker! |
Ref: #2708
The
Doctrine\ORM\Mapping\ClassMetadataInfo
class is deprecated in ORM 2.x and removed entirely in 3.0, withDoctrine\ORM\Mapping\ClassMetadata
being the replacement.Doctrine\ORM\Mapping\ClassMetadata
exists in 2.x as a subclass ofDoctrine\ORM\Mapping\ClassMetadataInfo
, so no version conditional behaviors are really needed here, therefore, this PR just adds both ORM classes to some existing doc block types and assertions (I'm aware there are other places using the deprecatedClassMetadataInfo
class but the changes here just unblocked being able to run a number of tests locally on ORM 3.0 for now).