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

drop annotation support with entities #1126

Merged
merged 1 commit into from
May 24, 2022

Conversation

jrushlow
Copy link
Collaborator

No description provided.

@jrushlow jrushlow added the Feature New Feature label May 19, 2022
composer.json Outdated
@@ -42,7 +42,8 @@
"sort-packages": true
},
"conflict": {
"doctrine/orm": "<2.10"
"doctrine/orm": "<2.10",
"doctrine/doctrine-bundle": "<2.4"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.4 introduces support for attributes... this allows use to remove some of our attribute conditionals. or at the very least - we would only need to verify the bundle is installed..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side note - we already have doctrine-bundle: ^2.4 as a dev dependency.

@jrushlow jrushlow force-pushed the legacy/doctrine branch 2 times, most recently from 8e958a8 to b09fdd8 Compare May 19, 2022 15:49
src/Maker/MakeEntity.php Outdated Show resolved Hide resolved
Comment on lines +206 to +203
if (!$this->doesEntityUseAttributeMapping($entityClassDetails->getFullName())) {
throw new RuntimeCommandException(sprintf('Only attribute mapping is supported by make:entity, but the <info>%s</info> class uses a different format. If you would like this command to generate the properties & getter/setter methods, add your mapping configuration, and then re-run this command with the <info>--regenerate</info> flag.', $entityClassDetails->getFullName()));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one that we need to keep and determine if

  1. AttributeMapping is not used
  2. If somehow - AttributeMapping was being used but the class had @ORM\Entity.. type annotations.
    Then we would throw this exception..

@jrushlow jrushlow marked this pull request as ready for review May 20, 2022 22:57
@jrushlow jrushlow added the Status: Needs Review Needs to be reviewed label May 20, 2022
{
return $this->doesClassUseDriver($className, AnnotationDriver::class);
}

public function doesClassUsesAttributes(string $className): bool
{
return $this->doesClassUseDriver($className, AttributeDriver::class);
}

public function isDoctrineSupportingAttributes(): bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After we remove that one if statement we talked about in this PR, is this used anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be when we're all said and done, but make:user && make:reset-password are still calling on this.. they need to be refactored after this PR && the CSM one.


return $this->doctrineHelper->isClassAnnotated($className);
}

/** @legacy Drop when Annotations are no longer supported */
private function doesEntityUseAttributeMapping(string $className): bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're keeping this, remove the comment above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to keep this. But for the same reasons above, we'll need to remove it in a final "clean up" PR.

@@ -579,10 +579,10 @@ private function addSingularRelation(BaseRelation $relation): void

$this->addGetter(
$relation->getPropertyName(),
$relation->getCustomReturnType() ?: $typeHint,
$relation->getCustomReturnType() ?? $typeHint,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit pick, but I don't think ?? is needed here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it still is because the return type for BaseRelation::getCustomReturnType(): ?string.

Before, we just had a "string" type hint instead of an actual return type. Now, we have to watch out for uninitialized properties. Side note: we're doing a lot of cleanup in CSM in the respective PR.

@jrushlow jrushlow changed the title WIP - drop annotation support with entities drop annotation support with entities May 24, 2022
@weaverryan
Copy link
Member

Thanks Jesse!

@weaverryan weaverryan merged commit 09f9cbf into symfony:main May 24, 2022
@jrushlow jrushlow deleted the legacy/doctrine branch May 24, 2022 14:26
weaverryan added a commit that referenced this pull request May 26, 2022
This PR was squashed before being merged into the 1.0-dev branch.

Discussion
----------

[csm] strict typing && legacy code removal

- drops CSM annotation support
- cleans up legacy CSM code
- implements strict typing

- [x] Depends on #1126

Commits
-------

ffc80c4 [csm] strict typing && legacy code removal
@jrushlow jrushlow mentioned this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants