-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add automatic type detection for Embedded. #8724
Conversation
2f97e71
to
dbab6cf
Compare
$this->embeddedClasses[$mapping['fieldName']] = [ | ||
'class' => $this->fullyQualifiedClassName($mapping['class']), | ||
'columnPrefix' => $mapping['columnPrefix'], | ||
'columnPrefix' => $mapping['columnPrefix'] ?? null, |
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.
🤔 what does this have to do with the rest of your PR?
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 assume phpstan failure they mentioned in the PR description.
@@ -322,9 +322,11 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) | |||
? $this->evaluateBoolean($embeddedMapping['use-column-prefix']) | |||
: true; | |||
|
|||
$class = isset($embeddedMapping['class']) ? (string) $embeddedMapping['class'] : null; |
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.
Let's inline this on line 327 and get rid of this one-time variable?
$mapping['class'] = $type->getName(); | ||
} | ||
} | ||
|
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.
You need to check here again that class isset or otherwise throw an exception. If not, then line 3616 will throw a notice accessing mapping class that does not exist.
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.
Actually the validation is done "late" in ClassMetadataFactory::doLoadMetadata
as per #1133 - this should probably be changed, but not now.
$this->embeddedClasses[$mapping['fieldName']] = [ | ||
'class' => $this->fullyQualifiedClassName($mapping['class']), | ||
'columnPrefix' => $mapping['columnPrefix'], | ||
'columnPrefix' => $mapping['columnPrefix'] ?? null, |
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 assume phpstan failure they mentioned in the PR description.
* Mark 2.8.x as unmaintained, and 2.9.x as current * Fix ClassMetadataInfo template inference * Fix metadata cache compatibility layer * Bump doctrine/cache patch dependency to fix build with lowest deps * Add generics to parameters * Add note about performance and inheritance mapping (#8704) Co-authored-by: Claudio Zizza <[email protected]> * Adapt flush($argument) in documentation as it's deprecated. (#8728) * [GH-8723] Remove use of nullability to automatically detect nullable status (#8732) * [GH-8723] Remove use of nullability to automatically detect nullable status. * [GH-8723] Make Column::$nullable default to false again, fix tests. * Add automatic type detection for Embedded. (#8724) * Add automatic type detection for Embedded. * Inline statement. Co-authored-by: Benjamin Eberlei <[email protected]> Co-authored-by: Grégoire Paris <[email protected]> Co-authored-by: Vincent Langlet <[email protected]> Co-authored-by: Andreas Braun <[email protected]> Co-authored-by: Fran Moreno <[email protected]> Co-authored-by: Juan Iglesias <[email protected]> Co-authored-by: Claudio Zizza <[email protected]> Co-authored-by: Yup <[email protected]> Co-authored-by: Benjamin Eberlei <[email protected]>
Great work on #8439 and #8589.
Following it - This adds same automatic type detection when using typed properties for Embedded.
Needs help on PHPStan failure.
Edit: Figured it out.