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

Add automatic type detection for Embedded. #8724

Merged
merged 3 commits into from
May 31, 2021

Conversation

Warxcell
Copy link
Contributor

@Warxcell Warxcell commented May 25, 2021

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.

@Warxcell Warxcell force-pushed the add_embeddable branch 3 times, most recently from 2f97e71 to dbab6cf Compare May 25, 2021 15:54
$this->embeddedClasses[$mapping['fieldName']] = [
'class' => $this->fullyQualifiedClassName($mapping['class']),
'columnPrefix' => $mapping['columnPrefix'],
'columnPrefix' => $mapping['columnPrefix'] ?? null,
Copy link
Member

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?

Copy link
Member

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;
Copy link
Member

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();
}
}

Copy link
Member

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.

Copy link
Member

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,
Copy link
Member

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.

@beberlei beberlei merged commit 75b4b88 into doctrine:2.9.x May 31, 2021
@beberlei beberlei added this to the 2.9.2 milestone May 31, 2021
beberlei added a commit that referenced this pull request May 31, 2021
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants