Skip to content

Use object typehint when generating entities#872

Merged
jrushlow merged 1 commit intosymfony:mainfrom
HypeMC:object-typehint
Apr 26, 2022
Merged

Use object typehint when generating entities#872
jrushlow merged 1 commit intosymfony:mainfrom
HypeMC:object-typehint

Conversation

@HypeMC
Copy link
Member

@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

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
Member 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
Member 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.

2 participants