-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
Conversation
There was a problem hiding this 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
src/Util/ClassSourceManipulator.php
Outdated
@@ -1113,6 +1113,8 @@ private function getEntityTypeHint($doctrineType) | |||
return '\\'.\DateInterval::class; | |||
|
|||
case 'object': | |||
return \PHP_VERSION_ID < 70200 ? null : 'object'; |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrushlow Done
There was a problem hiding this comment.
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.
There was a problem hiding this 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
Use object typehint when adding object entity fields.