-
Notifications
You must be signed in to change notification settings - Fork 45
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
Make container-interop a forwards-compatible polyfill for PSR-11 #97
base: master
Are you sure you want to change the base?
Make container-interop a forwards-compatible polyfill for PSR-11 #97
Conversation
Per discussion on php-fig/container#38, this patch updates the three shipped interfaces to instead become class aliases for the official PSR-11 interfaces. This allows implementing libraries to immediately switch to PSR-11 typehints/implementations while retaining backwards compatibility with container-interop. The patch also includes documentation of workflows for moving from container-interop to PSR-11 for both package and application authors.
Thanks for the catch, @boesing! Co-authored-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
I wonder if abandoned packages can publish new releases to packagist. |
If they cannot, the maintainers can "un-abandon" it, sync, and then re-abandon. |
Looks good, thank you! Would there be any conflict caused by implementing the same interface twice? (now that these classes are aliases) |
@mnapoli Good point. For implementing libraries/projects, this will lead to a fatal error:
Consuming libraries/projects won't have any issues. |
maybe releasing v2.0 of this component would be a good idea rather than having a new minor version. This would provide proper migration path for implementing libraries/components. So the only change n v2 would be the Actually, there are some laminas components consuming container-interop tho. |
@mnapoli I'd forgotten the whole So yes - this would require a v2 release, as implementing libraries still need to make a change. However, as @boesing notes, the changes in implementing libraries can happen in a minor release instead of a major release, which is really the whole goal of doing this. |
Has anyone tried if this trips psalm or phpstan in any way, before we move on with this approach? |
@Ocramius there were issues with the Thus said, when using composer autoloader to provide the alias, we should be good to go. But I can check that tomorrow in a large application using tons of these interfaces. |
I've executed this in our project and I receive exactly 1 static-analysis error for this case: I am actually unsure if thats a bug in psalm as the container mentioned does definitely implement that interface. |
I think that really needs to be tried out on a playground with an
autoloader, not on psalm.dev
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
…On Tue, Aug 17, 2021 at 11:50 AM Maximilian Bösing ***@***.***> wrote:
I've executed this in our project and I receive exactly 1 static-analysis
error for this case:
https://psalm.dev/r/d0893a607e
I am actually unsure if thats a bug in psalm as the container mentioned
does definitely implement that interface.
When switching the class_alias back to its original, psalm has no issue:
https://psalm.dev/r/5e5acaed94
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABFVEFL34NF6YBD33IEQBLT5IWFZANCNFSM5B4RERSQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
This error is reproduced from the project I have scanned. I just added it to psalm.dev for better understanding on whats going on. I added this branch to our composer dependencies, updated, removed the interop Interface from the laminas servicemanager servicelocator and ran psalm. Do you have something specific in mind when you say that this needs to be tried out on a playground with autoloader? I can create a dedicated github project 🤷🏼♂️ |
It is indeed an error within psalm which is issued by vimeo/psalm#6325 and will be fixed with vimeo/psalm#6327. |
@weierophinney Yes, I think from all informations we got, having a new major in here would be the best option for now. So I am 100% on-board here, if no one has other feedback or doubts, I think we are good to go. |
@mnapoli We have a green light! Ping me when you've tagged; we'd like to start rolling out as soon as you have! |
@mnapoli Ping - can you merge, and then tag and release v2.0.0 with these changes, please? Thanks in advance! |
I just pinged @moufmouf to get a review from him. This is a v2 so I prefer to find a bit of time to review it, will try to do asap 😓 |
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.
We probably need to update the readme to replace references to 1.3.0 with references to 2.0.0.
I have a question though.
Library implementors will require container-interop/container-interop ^2
as a dependency.
This means as an end user, if your project depends on many libraries requiring container-interop/container-interop
, they must all migrate in 2.0 version for your project to migrate.
@boesing What is the rationale to tag a 2.0 rather than a 1.3? I'm not sure I understand.
@moufmouf when tagging 1.3, upstream projects implementing both PSR-11 and interop Interfaces will immediately break. |
@moufmouf here are code examples on why it should be a major release Upstream components can require v2 and fully migrate to PSR-11 in a minor (and then also drop interop while conflicting with it in another minor if they want to) without the need of releasing a new major on their side. Maybe conflicting with v1 of interop could be a way, too but I doubt that projects require interop directly. |
@mnapoli @moufmouf Is there anything left open which blocks this PR? |
Co-authored-by: David Négrier <d.negrier@thecodingmachine.com>
Co-authored-by: David Négrier <d.negrier@thecodingmachine.com>
Done on that front! |
|
||
- Create a new minor release with the following changes to your package: | ||
- Require `psr/container` (`composer require psr/container:^1.1`) | ||
- Update your minimum supported container-interop/container-interop version to 1.3.0 (`composer require "container-interop/container-interop:^1.3"`) |
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 think we have to change this as well, right?
What I do actually wondering about is, how we ensure compatibility for both v1 and v2 here?
Can this be achieved?
Sadly thats months ago that I spent time on that front and thus I can't remember. Maybe I find some time after PHP 8.1 and stuff to outline this.
Per discussion on php-fig/container#38, this patch updates the three shipped interfaces to instead become class aliases for the official PSR-11 interfaces. This allows implementing libraries to immediately switch to PSR-11 typehints/implementations while retaining backwards compatibility with container-interop.
The patch also includes documentation of workflows for moving from container-interop to PSR-11 for both package and application authors.