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

set default value for Channel taxCalculationStrategy #11418

Merged
merged 2 commits into from
Sep 7, 2020

Conversation

oallain
Copy link
Member

@oallain oallain commented May 3, 2020

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #11414
License MIT

@oallain oallain requested a review from a team as a code owner May 3, 2020 19:48
@lchrusciel lchrusciel added DX Issues and PRs aimed at improving Developer eXperience. RFC Discussions about potential changes or new features. labels May 4, 2020
Copy link
Contributor

@pamil pamil left a comment

Choose a reason for hiding this comment

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

What issue does it solve?

@pamil
Copy link
Contributor

pamil commented May 6, 2020

Oh, I've just seen #11414. I'm not feeling comfortable with hardcoding the strategy, we should find some way to at least rely on some constraint or just use the first strategy that is available.

@lchrusciel
Copy link
Member

Neither do I, the current solution is a no-go right now.

Maybe we should provide such config through our factory service? This is the default method of creating new objects in Sylius.

@oallain
Copy link
Member Author

oallain commented May 15, 2020

Hi @lchrusciel @pamil ,

I create a ChannelFactory in Core, tell me if this is what you expected?

Copy link
Member

@lchrusciel lchrusciel left a comment

Choose a reason for hiding this comment

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

Seems good to me. Thanks Olivier!

src/Sylius/Component/Core/Factory/ChannelFactory.php Outdated Show resolved Hide resolved
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;

interface ChannelFactoryInterface extends FactoryInterface
Copy link
Member

Choose a reason for hiding this comment

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

Is this interface even needed, as we have the interface from component namespace?

public function createNamed(string $name): ChannelInterface;

If so, it should be extended rather than replaced.

Copy link
Member Author

Choose a reason for hiding this comment

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

IMHO, we need it while we don't have the covariance provided by PHP 7.4.

Copy link
Member

Choose a reason for hiding this comment

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

However, all of the current implementations, that are based on the previous interface cannot be changed, due to BC Policy. If we want to extend the previous implementation we need to extend the previous interface

@lchrusciel
Copy link
Member

Sorry for pushing it back and forth, but not spotting the current factory implementation was my mistake from the early beginning

@oallain oallain force-pushed the tax-calculation-strategy branch 2 times, most recently from eeb1267 to 5cb43bc Compare June 3, 2020 18:59
@probot-autolabeler probot-autolabeler bot added the Admin AdminBundle related issues and PRs. label Jun 15, 2020
@oallain oallain changed the base branch from master to 1.7 June 15, 2020 19:31
@oallain
Copy link
Member Author

oallain commented Jun 15, 2020

Hi @lchrusciel

All looks good, but Travis failed.
Can you (or anyone) can help me ?

Thanks

@mamazu
Copy link
Member

mamazu commented Jun 15, 2020

The reason some of your tests may fail is because currently the master is broken. So just wait for them to fix it and then rebase again. (Or fix it yourself and make a separate pull request)

@lchrusciel
Copy link
Member

We can try to rebase now, it should work ;)

@oallain oallain force-pushed the tax-calculation-strategy branch 2 times, most recently from 67c09ca to 70a40c6 Compare June 16, 2020 17:58
@probot-autolabeler probot-autolabeler bot added the Maintenance CI configurations, READMEs, releases, etc. label Jun 16, 2020
@oallain
Copy link
Member Author

oallain commented Jun 18, 2020

Hi @lchrusciel ,

Rebase is done, and "application" is green on Travis, but "doc" still red 😞

@mamazu
Copy link
Member

mamazu commented Jun 18, 2020

Can you rebase again now?

@oallain
Copy link
Member Author

oallain commented Jun 18, 2020

@mamazu ,

It's worse 😉

@mamazu
Copy link
Member

mamazu commented Jun 18, 2020

Hm, but the master is green. Very odd.

@oallain
Copy link
Member Author

oallain commented Jun 19, 2020

@mamazu

I changed target to master and it's green now :)

Thanks !

@oallain oallain force-pushed the tax-calculation-strategy branch 2 times, most recently from 1734369 to 281269e Compare June 27, 2020 15:12
@oallain
Copy link
Member Author

oallain commented Jun 27, 2020

Hello @lchrusciel @mamazu

I rebase (again) and now Travis is green 😄 (But Symfony/Insight is Pending 😂 )

Regards

@mamazu
Copy link
Member

mamazu commented Jun 29, 2020

Hm, someone from Sylius needs to restart this job.

@lchrusciel
Copy link
Member

Hey Olivier 👋

I didn't find time to take over this PR, however, I won't merge it without change to #11418 (comment). Right now this PR contains BC Break.

@oallain
Copy link
Member Author

oallain commented Jul 7, 2020

Hello,

I am facing a dilemma and I don't know what/how to do :

  1. Either the new Sylius\Component\Core\Factory\ChannelFactoryInterface extends Sylius\Component\Channel\Factory\ChannelFactoryInterface and in this case, the return types should be different but this is only possible with the covariance provided by PHP 7.4 - so BC with PHP < 7.4
  2. Either the new Sylius\Component\Core\Factory\ChannelFactoryInterface return Sylius\Component\Channel\Model\ChannelInterface and not Sylius\Component\Core\Model\ChannelInterface.
  3. Either keep this PR like this, however, all of the current implementations, that are based on the previous interface cannot be changed, like say Lukasz in set default value for Channel taxCalculationStrategy #11418 (comment) - so BC with older implementations

What is the best solution ?

@oallain
Copy link
Member Author

oallain commented Jul 7, 2020

I just pushed with solution 2) 😉

Looking forward to your feedback.

@mamazu
Copy link
Member

mamazu commented Jul 7, 2020

I would suggest option 1 with the return type not being type-hinted but just annotated in the doc type. Then psalm or phpstan or any other static code analysis tool can pick it up and it doesn't break things. (And this is also the best way to go in my opinion)

Option 2 is not great. Because the interface of the component is smaller than the interface of the core bundle (as far as I know) so this would also be sub-optimal.

Option 3: I don't know if there is already a branch in Sylius that is for 2.0 where those BC breaks will probably be bundled into. I also made a breaking change as a PR which also still has no place to go really.

@lchrusciel
Copy link
Member

Option 3 is a no-go for us. Option 2 is what we are doing for the last few years and this is what I would recommend. However, as @mamazu stated, probably improved option 1 (with docblock) is the best solution right now.

@oallain oallain force-pushed the tax-calculation-strategy branch 2 times, most recently from 94b23ef to 31f3e91 Compare September 1, 2020 08:33
@oallain
Copy link
Member Author

oallain commented Sep 1, 2020

Hello, @mamazu

This rebase is 💚 (green) 🎉

@lchrusciel lchrusciel changed the base branch from master to 1.8 September 7, 2020 09:35
@lchrusciel lchrusciel changed the base branch from 1.8 to master September 7, 2020 09:35
@lchrusciel lchrusciel changed the base branch from master to 1.7 September 7, 2020 09:37
@lchrusciel
Copy link
Member

The base of this pull-request was changed, you need fetch and reset your local branch
if you want to add new commits to this pull request. Reset before you pull, else commits
may become messed-up.

Unless you added new commits (to this branch) locally that you did not push yet,
execute git fetch origin && git reset "tax-calculation-strategy" to update your local branch.

Feel free to ask for assistance when you get stuck 👍

@lchrusciel lchrusciel merged commit 2436b84 into Sylius:1.7 Sep 7, 2020
@lchrusciel
Copy link
Member

Thanks, @oallain! 🥇

lchrusciel added a commit that referenced this pull request Sep 7, 2020
…nor improvements (lchrusciel)

This PR was merged into the 1.7 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.7
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | fixes for #11418
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.7 branch (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

4fe2f3c [Channel] Fix bc-breaking changes in ChannelFactory
@oallain oallain deleted the tax-calculation-strategy branch September 9, 2020 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admin AdminBundle related issues and PRs. DX Issues and PRs aimed at improving Developer eXperience. Maintenance CI configurations, READMEs, releases, etc. RFC Discussions about potential changes or new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Channel class, default taxCalculationStrategy value
4 participants