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

[Contracts] Add parameter type declarations to contracts #33497

Merged
merged 1 commit into from
Nov 9, 2019

Conversation

derrabus
Copy link
Member

@derrabus derrabus commented Sep 7, 2019

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #32179
License MIT
Doc PR N/A

This PR proposes to create a php 7.2 version of the contracts that maintains BC with Symfony 4. The PR suggests to bump the contracts version to 1.2 2.0 on the master branch. We would still be able to maintain the contracts 1.1 branch on Symfony's 4.4 branch, should we need to patch the current contracts in the future.

This move would allow us to add parameter type declarations to existing contracts interfaces and make use of them in Symfony 5. Especially the Translation and EventDispatcher components benefit a lot from this bump, imho.

Contracts that will be added on the road to Symfony 6 wouldn't be restricted to the capabilities of php 7.1, which would be another benefit in my opinion.

1 Test currently fail because the translator is called with null as translation key. That possibility should be deprecated imho.

@carsonbot carsonbot added Status: Needs Review RFC RFC = Request For Comments (proposals about features that you want to be discussed) labels Sep 7, 2019
@nicolas-grekas
Copy link
Member

Test currently fail because the translator is called with null as translation key. That possibility should be deprecated imho.

We recently ensured that the implementation accepts null. Note that the interface can be string while the implementation (the trait) is ?string. That'd be perfectly fine to me. You could update the PR in that direction.

About the PR in general, we don't have the infrastructure to split symfony/symfony in two branches in symfony/contracts, as this PR would require.

But since v1.1 is going to be frozen as soon as 4.4.0 is out, we could bump contracts to 1.2 in December and work around the issue.

That'd work, right?

@derrabus
Copy link
Member Author

derrabus commented Sep 7, 2019

Test currently fail because the translator is called with null as translation key. That possibility should be deprecated imho.

We recently ensured that the implementation accepts null. Note that the interface can be string while the implementation (the trait) is ?string. That'd be perfectly fine to me. You could update the PR in that direction.

All right, will do.

About the PR in general, we don't have the infrastructure to split symfony/symfony in two branches in symfony/contracts, as this PR would require.

I’m not familiar with the tooling you’re using to perform the subtree splits, but since all components are already split off the monorepo with multiple branches, I’m confident that this is possible.

But since v1.1 is going to be frozen as soon as 4.4.0 is out, we could bump contracts to 1.2 in December and work around the issue.

That'd work, right?

Certainly. But since the plan is to release 4.4.0 and 5.0.0 simultaneously, we would need to wait for 5.1 to merge this PR. Also, we wouldn’t be able to ship a 1.1 patch release anymore once we’ve bumped. If we could get the subtree split with two branches to work, that would be the the option I’d prefer.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 7, 2019

we wouldn’t be able to ship a 1.1 patch release anymore once we’ve bumped.

that's why we need to wait a bit, so we can freeze it completely :)

If we could get the subtree split with two branches to work, that would the the option I’d prefer.

we need a plan that would survive if we don't manage to have this tool. last time we checked, we decided it was too difficult.

I think we should bump to v2 btw (which means we should allow v2 in all composer.json that reference any contracts). That's how we do minor PHP bumps using Symfony policies. Relying on composer to block installing v1.2 because PHP 7.1 is used is a foot gun that hit our users before (remember symfony/intl when it shipped different versions based on the presence of ext-intl). I know others do it, but that's not a reason to do it too, IMHO.

@nicolas-grekas
Copy link
Member

Oh btw, please borrow from nicolas-grekas@8cebfcd:)

@derrabus
Copy link
Member Author

derrabus commented Sep 7, 2019

If we could get the subtree split with two branches to work, that would the the option I’d prefer.

we need a plan that would survive if we don't manage to have this tool. last time we checked, we decided it was too difficult.

I'll tinker a bit with subtree splits and get back to you. I'm not ready to give up just yet.

I think we should bump to v2 btw (which means we should allow v2 in all composer.json that reference any contracts).

That would mean, we would require ^1.1|^2 in Symfony 4.4 and ^2 in Symfony 5.x (whenever we feel ready to bump). Fine by me.

That's how we do minor PHP bumps using Symfony policies.

All changes in this PR including the php bump are non-breaking according to (my understanding of) SemVer. But it's of course okay to be stricter than SemVer, so 2.0 it is. 😃

@derrabus
Copy link
Member Author

derrabus commented Sep 7, 2019

See #33500 for allowing Contracts 2 in Symfony 4.4.

@derrabus
Copy link
Member Author

derrabus commented Sep 7, 2019

I've cherry-picked #33500 into this PR and switched all contracts to 2.0.

@derrabus derrabus force-pushed the improvement/typed-contracts branch 4 times, most recently from c046917 to d65ea8f Compare September 8, 2019 10:43
@derrabus
Copy link
Member Author

derrabus commented Sep 8, 2019

I managed to split off a contracts repository with a 1.1 branch (from #33500) and a master branch (from this PR): https://github.com/derrabus/symfony-contracts-split

mkdir symfony-contracts
cd symfony-contracts
git init --bare
cd ../symfony
git checkout improvement/allow-contracts-2
git subtree split --prefix=src/Symfony/Contracts -b contracts-1.1
git push ../symfony-contracts contracts-1.1:1.1
git checkout improvement/typed-contracts
git subtree split --prefix=src/Symfony/Contracts -b contracts-master
git push ../symfony-contracts contracts-master:master

Your current tooling is a black box for me, but as far as I can tell, the master of the symfony/contracts repository is split off of the 4.4 branch of symfony/symfony. It shouldn't be too hard to set up 2 branches for the split. Suggested mapping:

symfony/symfony symfony/contracts
4.4 1.1 or 1.x
master master

@derrabus derrabus force-pushed the improvement/typed-contracts branch 2 times, most recently from 7df6c03 to 62f926d Compare September 8, 2019 13:13
@nicolas-grekas nicolas-grekas added this to the 5.0 milestone Sep 8, 2019
fabpot added a commit that referenced this pull request Sep 8, 2019
This PR was merged into the 4.4 branch.

Discussion
----------

Allow version 2 of the contracts package

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | prepares #33497
| License       | MIT
| Doc PR        | N/A

The plan is to release a version 2 of the contracts package that will require php 7.2 but remains compatible to Symfony 4.

Commits
-------

a1ee320 Allow version 2 of the contracts package.
@derrabus derrabus changed the title [RFC][Contracts] Add parameter type declarations to contracts [Contracts] Add parameter type declarations to contracts Oct 1, 2019
@nicolas-grekas
Copy link
Member

@derrabus could you please rebase this PR and ensure it's ready? It might be time to do it.

@derrabus
Copy link
Member Author

derrabus commented Nov 8, 2019

Rebase done.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I've rebased the PR to relaunch tests. Just one question.

src/Symfony/Bundle/FrameworkBundle/composer.json Outdated Show resolved Hide resolved
nicolas-grekas added a commit to derrabus/symfony that referenced this pull request Nov 8, 2019
…contracts (derrabus)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[Contracts] Add parameter type declarations to contracts

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony#32179
| License       | MIT
| Doc PR        | N/A

This PR proposes to create a php 7.2 version of the contracts that maintains BC with Symfony 4. The PR suggests to bump the contracts version to ~~1.2~~ 2.0 on the master branch. We would still be able to maintain the contracts 1.1 branch on Symfony's 4.4 branch, should we need to patch the current contracts in the future.

This move would allow us to add parameter type declarations to existing contracts interfaces and make use of them in Symfony 5. Especially the Translation and EventDispatcher components benefit a lot from this bump, imho.

Contracts that will be added on the road to Symfony 6 wouldn't be restricted to the capabilities of php 7.1, which would be another benefit in my opinion.

~~<sup>1</sup> Test currently fail because the translator is called with `null` as translation key. That possibility should be deprecated imho.~~

Commits
-------

bf515e1 Add parameter type declarations to contracts.
@nicolas-grekas nicolas-grekas force-pushed the improvement/typed-contracts branch 6 times, most recently from 646d954 to 55b6cf0 Compare November 9, 2019 09:08
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Before merging, we should tag v1.1.8 of symfony/contracts and symfony/http-client-contracts
And just after merging, we should tag v2.0.0 of symfony/contracts and symfony/*-contracts

@fabpot
Copy link
Member

fabpot commented Nov 9, 2019

Thank you @derrabus.

fabpot added a commit that referenced this pull request Nov 9, 2019
…ts (derrabus)

This PR was merged into the 5.0-dev branch.

Discussion
----------

[Contracts] Add parameter type declarations to contracts

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32179
| License       | MIT
| Doc PR        | N/A

This PR proposes to create a php 7.2 version of the contracts that maintains BC with Symfony 4. The PR suggests to bump the contracts version to ~~1.2~~ 2.0 on the master branch. We would still be able to maintain the contracts 1.1 branch on Symfony's 4.4 branch, should we need to patch the current contracts in the future.

This move would allow us to add parameter type declarations to existing contracts interfaces and make use of them in Symfony 5. Especially the Translation and EventDispatcher components benefit a lot from this bump, imho.

Contracts that will be added on the road to Symfony 6 wouldn't be restricted to the capabilities of php 7.1, which would be another benefit in my opinion.

~~<sup>1</sup> Test currently fail because the translator is called with `null` as translation key. That possibility should be deprecated imho.~~

Commits
-------

4de3773 Add parameter type declarations to contracts.
@fabpot fabpot merged commit 4de3773 into symfony:master Nov 9, 2019
@Tobion
Copy link
Member

Tobion commented Nov 9, 2019

we should tag v2.0.0 of symfony/contracts

Do we still want to publish the contract meta package at all? Wouldn't it make sense to not tag it anymore just as it was planned to not tag v5 of symfony/symfony?

@nicolas-grekas
Copy link
Member

I think we still have to publish the metapackage for our CI at least. Not tagging 5.0/2.0 creates burden on our side we don't have much time to deal with IMHO.

@derrabus derrabus deleted the improvement/typed-contracts branch November 9, 2019 18:22
@derrabus
Copy link
Member Author

derrabus commented Nov 9, 2019

we should tag v2.0.0

We could go with a beta first and tag v2.0.0 together with Symfony 5.0.0. Maybe we find an issue during the Symfony 4.4/5.0 beta test that we want to fix before tagging a final 2.0.0 on the contracts.

I think we still have to publish the metapackage for our CI at least.

Should we add a conflict rule for symfony/contracts to the skeleton then, like we have it for symfony/symfony?

https://github.com/symfony/skeleton/blob/cd58faa216e3a667efd03aecfdecc7296de38850/composer.json#L56-L58

@derrabus
Copy link
Member Author

derrabus commented Nov 9, 2019

Tests on 4.4 are broken now because we still allow symfony/contracts v2 on symfony/symfony 4.4 but broke compatibility on the event dispatcher. Maybe it's not a bad idea after all to drop the metapacke in CI?

@nicolas-grekas
Copy link
Member

We should unallow 2 from 4.4. Dropping the metapackage would break master then. And we (I) have better to do than this...

@derrabus
Copy link
Member Author

derrabus commented Nov 9, 2019

#34307

@fabpot fabpot mentioned this pull request Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed) Status: Reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants