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

Use object typehint when generating entities #872

Merged
merged 1 commit into from Apr 26, 2022
Merged

Use object typehint when generating entities #872

merged 1 commit into from Apr 26, 2022

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented May 8, 2021

Use object typehint when adding object entity fields.

Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

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

I like the idea! Anytime we can set explicit types, the better. We do however need to move the PHP version conditional logic into the PhpCompatUtil::class

@@ -1113,6 +1113,8 @@ private function getEntityTypeHint($doctrineType)
return '\\'.\DateInterval::class;

case 'object':
return \PHP_VERSION_ID < 70200 ? null : 'object';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check should be done in the PhpCompatUtil -> https://github.com/symfony/maker-bundle/blob/main/src/Util/PhpCompatUtil.php

Something along the lines of PhpCompatUtil::canUseObjectReturnType()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jrushlow Done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jrushlow Since the maker bundle now requires PHP 7.2.5+ I've removed all conditional logic.

@jrushlow jrushlow added Feature New Feature Status: Needs Work Additional work is needed labels May 10, 2021
@HypeMC HypeMC requested a review from jrushlow May 11, 2021 08:30
@HypeMC HypeMC changed the title Use object typehint for PHP >= 7.2 when generating entities Use object typehint when generating entities Apr 26, 2022
Copy link
Collaborator

@jrushlow jrushlow left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you @HypeMC

@jrushlow jrushlow added the Status: Reviewed Has been reviewed by a maintainer label Apr 26, 2022
@jrushlow jrushlow merged commit 5052c21 into symfony:main Apr 26, 2022
@HypeMC HypeMC deleted the object-typehint branch April 26, 2022 10:14
@jrushlow jrushlow mentioned this pull request May 4, 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 Work Additional work is needed Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants