Skip to content

Add automatic type detection for Embedded.#8724

Merged
beberlei merged 3 commits intodoctrine:2.9.xfrom
Warxcell:add_embeddable
May 31, 2021
Merged

Add automatic type detection for Embedded.#8724
beberlei merged 3 commits intodoctrine:2.9.xfrom
Warxcell:add_embeddable

Conversation

@Warxcell
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

? $this->evaluateBoolean($embeddedMapping['use-column-prefix'])
: true;

$class = isset($embeddedMapping['class']) ? (string) $embeddedMapping['class'] : null;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <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>
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