Skip to content

[DependencyInjection] Support psr/container v2 in contracts #41660

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

Closed
wants to merge 1 commit into from

Conversation

Firehed
Copy link
Contributor

@Firehed Firehed commented Jun 10, 2021

Q A
Branch? 6.0
Bug fix? no
New feature? no
Deprecations? no
Tickets --
License MIT
Doc PR --

This adds support for psr/container 2.x in contracts (and more specifically service-contracts. After digging through dependencies, I found this (which is required via console) as the last remaining place in my code that required the 1.x line.

@carsonbot carsonbot changed the title Support psr/container v2 in contracts [DependencyInjection] Support psr/container v2 in contracts Jun 10, 2021
@derrabus
Copy link
Member

This is a BC break. Let's target the 6.0 branch instead.

@derrabus derrabus added this to the 6.0 milestone Jun 10, 2021
@derrabus derrabus changed the base branch from 5.4 to 6.0 June 10, 2021 21:57
@Firehed
Copy link
Contributor Author

Firehed commented Jun 10, 2021

I'm totally fine with targeting 6.0 instead, but I don't believe this should result in a BC break. Narrowing return types (in this case, going from implicit mixed to explicit bool) is valid under LSP. I've got library code using both psr/container v1 and v2 in a build matrix with the added return type and it doesn't cause any problems.

Having said that, it's not exactly causing a burning issue for me so I'm fine with waiting for the later version.

@jderusse
Copy link
Member

Narrowing return types (in this case, going from implicit mixed to explicit bool) is valid under LSP. I've got library code using both psr/container v1 and v2 in a build matrix with the added return type and it doesn't cause any problems.

But it's the opposite for project that use symfony. It's a BC break for all classes that implement the interface.

Having a class without return type can implement the interface in 5.2 and being valid. But if you add a return type, the class will not be valid anymore

@Firehed
Copy link
Contributor Author

Firehed commented Jun 10, 2021

Certainly. But this only permits the newer interface, not force it. Any project requiring psr/container:1.x would continue to install that version and work without modification.

I suppose if a project is using Symfony and using their own Container implementation without explicitly requiring psr/container and instead relying on whatever Symfony grabs it could break, but that a) seems unlikely to me and b) that's already a misconfigured project by relying on an indirect dependency.

Again, I won't belabor the point (and you'd certainly know Symfony usage characteristics better than I would), but for any project using this with correctly-declared dependencies, it should be completely safe and not a BC break. I'm under no pressure; just trying to get a line removed from composer outdated :) Up to you!

@stof
Copy link
Member

stof commented Jun 11, 2021

Certainly. But this only permits the newer interface, not force it. Any project requiring psr/container:1.x would continue to install that version and work without modification.

But this changes our own signature due to allowing the new interface, which is a BC break for our own interface.

I suppose if a project is using Symfony and using their own Container implementation without explicitly requiring psr/container and instead relying on whatever Symfony grabs it could break, but that a) seems unlikely to me and b) that's already a misconfigured project by relying on an indirect dependency.

Projects would be totally fine in requiring the symfony package if what they implement is Symfony's ContainerInterface (which extends the PSR one). The PSR interface is used by the Symfony package, not by the project. But the new major version of psr/container impacts the public API of the Symfony interface.

@stof
Copy link
Member

stof commented Jun 11, 2021

This should also update other packages requiring service-contracts to allow the new major version of the contracts (as this change will require bumping the major version)

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jun 12, 2021

I'm closing because we're not ready yet. There are many more changes we need to do before doing this change (eg prepare a deprecation layer, bump the major version of contracts, etc.)

@CodeByZach
Copy link

Is there a timeline on when this dependency can be upgraded?

image

symfony/service-contracts#1
symfony/contracts#3

@derrabus
Copy link
Member

End of November.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants