-
Notifications
You must be signed in to change notification settings - Fork 84
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
Fix getId/id return type for entities #208
Conversation
@@ -1,19 +1,23 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
|
|||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> | |||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" |
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've set this "header" as it's done at sylius/sylius
d657369
to
a4fbe03
Compare
@@ -45,64 +44,64 @@ public function getCompany(): ?string | |||
return $this->company; | |||
} | |||
|
|||
public function getTaxId(): ?string | |||
public function setCompany(?string $company): void |
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.
Methods re-arranged in order of class variables declaration/doctrine entities declaration
@lchrusciel review please |
<field name="firstName" column="first_name" type="string" /> | ||
<field name="lastName" column="last_name" type="string" /> | ||
<field name="company" column="company" type="string" nullable="true" /> | ||
<field name="street" column="street" type="string" /> | ||
<field name="city" column="city" type="string" /> | ||
<field name="postcode" column="postcode" type="string" /> | ||
<field name="countryCode" column="country_code" type="string" /> | ||
<field name="provinceCode" column="province_code" type="string" nullable="true" /> | ||
<field name="provinceName" column="province_name" type="string" nullable="true" /> |
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.
Why did you want to normalize mappings by adding these default values that are not necessary? The same applies to changes in other mappings
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.
How come column type is not a necessary field? Why rely on doctrine to have expected defaults instead of setting correct type explicitly?
There is difference in how source code is written at App\
level and Sylius\Sylius
level.
This is as much documentation as correct way to write entity mappings.
Besides, this is the way all sylius/sylius mappings are done.
https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Resources/config/doctrine/model/Order.orm.xml
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.
The default value of type is string
, so IMO there is no need to add it here, as they weren't defined before, especially in the PR with the title Fix getId/id return type for entities
, if you would like to change that, it should be done in the separate PR
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.
Doctrine mappings and entity fields types are quite related. Which issue will be solved by moving this to separate PR?
Please ask for 3rd opinion within the core team. Personally I don't see what there to discuss, sylius/sylius
defines explicit doctrine mappings and that's how it should be done.
If you have different opinion on the matter -- please open RFC at sylius/sylius
to remove string type
definition from mappings.
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.
@diimpp you've opened a PR with fixing getId return types, but you've also refactored other methods and the corresponding mapping, this refactoring should be done in a separate PR.
And about type
field, in Sylius sometimes we define explicitly type and sometimes we don't, so there is no one proper way based on Sylius repository 😃 For me, and also for doctrine documentation, type
is an optional field, so there is no need to define it, especially if they weren't configured before.
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.
And fyi, I've already asked @Zales0123 and @lchrusciel for other opinions 😃
@@ -64,12 +63,12 @@ public function __construct( | |||
$this->taxRate = $taxRate; | |||
} | |||
|
|||
public function getId() | |||
public function getId(): ?int |
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 would be for leaving it as it was before, without return type to keep id more customizable and consistent with all Sylius resources. I know that our mapping is configured for using integers, but it is relatively easy to change the strategy to use for example UUIDs instead of integers.
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 would agree that getId(): ?int
is opinionated, but not because somebody might want to make that UUID, but because sylius resource bundle doesn't define type-hint.
Though this is concrete implementation that you're marking final. In such case it's totally alright to make it int
and not to support some doctrine hacks for 3rd party.
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.
Did you see, that BillingData id is already int
in class, but ShopBillingData
is not? This is inconsistency and my PR is solving this as well.
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.
Should Invoice
's protected string $id
became @mixed
as well and constructor's string
type-hint removed, because somebody might want to change DB id to int?
@diimpp Sorry for that, especially that the PR have been opened for a long time, but I'm closing it as these are the changes that we don't want to have in this plugin. Of course, feel free to share your thoughts about that if you want to. |
@GSadee same change to the RefundPlugin was accepted. Sylius/RefundPlugin#199 How come you're closing this? |
I've rebased PR to the current master, I can remove |
@GSadee @Zales0123 @CoderMaggie hey guys, closure of this PR needs to be re discussed. There are bugs, that this PR closes and very similar PR for RefundPlugin was merged. I've answered above for all raised points. |
Hello @diimpp! I once again, after @GSadee, apologise for such a long response time. Going straight to the problems about the review here.
Cheers and sorry one more time for such a delay in answer 🖖 |
@Zales0123 Hi, thank you for update.
|
Changes are non BC, modification of mapping does not result in any new SQL statements
Fixes #206