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

Wrong getId type-hint, it should be nullable #189

Closed
diimpp opened this issue Feb 14, 2020 · 0 comments · Fixed by #199
Closed

Wrong getId type-hint, it should be nullable #189

diimpp opened this issue Feb 14, 2020 · 0 comments · Fixed by #199
Labels
Bug Confirmed bugs or bugfixes.

Comments

@diimpp
Copy link
Member

diimpp commented Feb 14, 2020

Hello,

Those entities won't have an ID after construction as they those IDs are assigned by doctrine, but at the same time getId/id type-hints for them are too restrictive.

--- getId(): int
+++ getId(): ?int

https://github.com/Sylius/RefundPlugin/blob/master/src/Entity/CreditMemoSequence.php
https://github.com/Sylius/RefundPlugin/blob/master/src/Entity/CustomerBillingData.php
https://github.com/Sylius/RefundPlugin/blob/master/src/Entity/LineItem.php
https://github.com/Sylius/RefundPlugin/blob/master/src/Entity/RefundPayment.php
https://github.com/Sylius/RefundPlugin/blob/master/src/Entity/ShopBillingData.php
https://github.com/Sylius/RefundPlugin/blob/master/src/Entity/TaxItem.php

LineItem and TaxItem have both getId and id methods, but CustomerBillingData and ShopBillingData doesn't, while they have similar methods schema.

I guess spec would need to be changed as well with something like

    function it_has_no_id_by_default(): void
    {
        $this->getId()->shouldReturn(null);
    }

https://github.com/Sylius/Sylius/blob/master/src/Sylius/Component/Payment/spec/Model/PaymentSpec.php#L27

Other thing that I've noticed, that LineItem and TaxItem id doctrine definition doesn't have AUTO keyword, if it means anything.
https://github.com/Sylius/RefundPlugin/blob/master/src/Resources/config/doctrine/LineItem.orm.xml#L6

@Zales0123 Zales0123 added the Bug Confirmed bugs or bugfixes. label Feb 16, 2020
lchrusciel added a commit that referenced this issue Mar 9, 2020
This PR was merged into the 1.0-dev branch.

Discussion
----------

Fixes #189 

Commits
-------

2f2c64f Fix getId/id return typehints for entities
56bf2c6 Normalize doctrine fields mappings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bugs or bugfixes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants