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.
🤔 what does this have to do with the rest of your PR?
There was a problem hiding this comment.
I assume phpstan failure they mentioned in the PR description.
| ? $this->evaluateBoolean($embeddedMapping['use-column-prefix']) | ||
| : true; | ||
|
|
||
| $class = isset($embeddedMapping['class']) ? (string) $embeddedMapping['class'] : null; |
There was a problem hiding this comment.
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.
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.
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.
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 <859964+SenseException@users.noreply.github.com> * 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 <kontakt@beberlei.de> Co-authored-by: Grégoire Paris <postmaster@greg0ire.fr> Co-authored-by: Vincent Langlet <VincentLanglet@users.noreply.github.com> Co-authored-by: Andreas Braun <git@alcaeus.org> Co-authored-by: Fran Moreno <franmomu@gmail.com> Co-authored-by: Juan Iglesias <juan.manuel.iglesias93@gmail.com> Co-authored-by: Claudio Zizza <859964+SenseException@users.noreply.github.com> Co-authored-by: Yup <warxcell@gmail.com> Co-authored-by: Benjamin Eberlei <kontakt@beberlei.de>
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.