-
Notifications
You must be signed in to change notification settings - Fork 3
Require php-http/promise 1.3.0 to be compatible with PHP 8.4 #53
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
base: main
Are you sure you want to change the base?
Conversation
baywet
left a comment
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.
Thanks for the contribution!
|
@hubipe as you can see we're getting quite a few failures in the CI. Here is a bit of history: we (the kiota team) originally contributed to the promise library to make it generic. But they decided to revert that change because it was breaking in some scenarios. So we've kept back the version of the library over time. @Ndiritu probably has more context here. I do have a few questions for you:
Thanks! |
|
@baywet As for your questions:
|
|
Thank you for the additional information. |
|
@baywet To be honest I don't. I don't use php-http/promise nor have any experience with the generics for PHPStan. |
|
Thank you for the additional information. The solution should not require anybody who has a kiota client to change their project configuration. So if the stubs can ship with this library as well, we can go ahead. As an alternative, what about creating a specialized type in the promise library, like generic promise, which would derive from the existing type? |
|
gentle reminder on this @hubipe to wrap things up. Alternatively, what's the biggest issue with NOT upgrading the dependency? People simply get a warning? But they can still install all kiota and microsoft graph packages? |
|
@baywet Thanks for the reminder, but I don't know how to wrap it up.
Which option would be best to wrap this PR up? |
|
Thank you for the additional information. Any solution that'd require consumers to update their PHP stan configuration wouldn't be acceptable. So would any solution that leads to sources breaking changes (even at linting/doc since it'd be disruptive). I believe this rules out 2, 3 and 4 from your last response. What about trying this:
We can then revert to the promise library to see whether they have any appetite to get this async promise as a contribution, or simply roll with that here if they push back. This should not be source breaking for anybody. Thoughts? |
|
@baywet Do I understand correctly, that I should create new Promise interface in this library, which should be extending Promise interface from the php-http/promise library and replace the return types to our Promise interface? |
that's what I'm suggesting yes. |
|
@baywet Will do on Thursday. |
|
@baywet Sooo, I tried to implement the new Although I copied the FulfilledPromise and RejectedPromise classes from the Http\Promise library as they were in the version 1.2.1, I couldn't make PHPStan stop complaining about the generics: Maybe would anyone know, how to handle this error? |
packages/abstractions/src/Authentication/AccessTokenProvider.php
Outdated
Show resolved
Hide resolved
|
Thanks for the additional work here. Is there any specific reason why they are final? |
I don't think so, they are final in the php-http/promise library, so I copied them as is. |
|
I removed the final keywords from the Fulfilled and Rejected promises |
|
I think re-implementing the promise types would effectively mean we no longer need a dependency on The goal of the generics effort was to improve the auto-completion experience with API clients so that we have IDEs suggest relevant methods/properties on the value a returned promise resolves to. Without this, the developer would need to check API docs/method docs to know the return type & add PHPDocs on their side for better auto-completion e.g. /** @var UserCollectionResponse|null **/
$users = $graphServiceClient->users()->get()->wait();
$users->... // resolves to relevant auto-completionI'd suggest exploring:
|
Agree. The interface Microsoft\Kiota\Abstraction\Promise\Promise extends Http\Promise\Promise only to be backwards compatible. If the interface wouldn't extend Http\Promise\Promise interface, then you could remove the
Stub files works only for PHPStan check in the library. It effectively replace the method signatures and annotation with those in the stub files, but only for the PHPStan check. That means, that these stub files would need every user's implementation, if they're using PHPStan for their libraries. That's because this library disclose Promise as a return type in the Promise::then() interface. Anyhow, what next? |
|
@hubipe |
|
@baywet this approach seems like the best compromise if we can't patch php-http. We'd need to change the generator namespace as well. A major rev, probably should drop the async approach. Thoughts? |
|
Thanks for joining here. To recap for my understanding:
Given our current funding situation, any breaking change solution is too much of a cost for us to bear as it requires coordination between the generator, packages for multiple languages, etc...) |
|
@hubipe thanks for the nudge here.
With that context in mind, do you have enough information to continue the work? |
|
Any possibility to get this done even with breaking changes? Long term not updating and letting the deprecated php-http/promise dependency stay also starts causing interruption to consumers as it starts breaking dependency chains and users not being able to update. See #45. E.g. several affected libraries which can't be updated used anymore with this deprecation: |
|
@julianschelker I think this would need somebody from the community to step up and fix at this point. Either the OP or yourself. Have a look at the conversation and let us know if you have any questions. |
|
Any updates on this issue? |
|
I have created a pull request to the php-http/promise library last week – php-http/promise#36 which would make promise library compatible with PHP 8.4 in the 1.2 branch. |
|
@hubipe Great work, hopefully it will be released soon |
|
The php-http/promise#36 has been merged and the new version 1.2.2 released. So I think, this MR could be closed and the rest of the Microsoft libraries waiting for this MR to be resolved could be finally merged? |
| /** | ||
| * A promise already fulfilled. | ||
| * | ||
| * @author Joel Wurtz <[email protected]> |
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 should remove the author here
| * | ||
| * @see https://promisesaplus.com/ | ||
| * | ||
| * @author Joel Wurtz <[email protected]> |
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.
Same comment about authors
| /** | ||
| * A rejected promise. | ||
| * | ||
| * @author Joel Wurtz <[email protected]> |
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.
Same comment for authors
|
@hubipe thank you for contributing there. |
The php-http/promise package in the 1.2.* branch contains the generics. See, the promise library had version 1.1. Then @Ndiritu (I think it was him) added the generics, and the 1.2 version has been released. It caused some problems, so they reverted it in the 1.3 version. They added support for PHP 8.4 in the 1.3 branch, but not to the 1.2 branch. The MR mentioned (and now merged as version 1.2.2) added support for PHP 8.4 on a branch with generics in it. |
|
Thank you for the additional information. So effectively kiota & microsoft graph clients will not be on the latest version of this dependency, but will have the compatibility with PHP 8.4, correct? |
|
@baywet Correct. Kiota dependency on php-http/promise will stay set to ~1.2.0, Whoever updates php-http/promise dependency to 1.2.2 will not have emmited deprecation warnings in PHP 8.4. |
|
Thank you for the additional information. The two main downsides I see here being:
The long term fix (assuming php promises doesn't make generic promises available in their mainline) is probably to unpin the version, and come up with our own generic promises definitions, which this PR was doing. But we can address that whenever people run into issues. Does that make sense? (I want to make sure I document the conclusion correctly, this way whenever those issues arise, we'll have context to come back to) |
I beg to differ. I opened this MR solely to allow installing PHP 8.4 on a project using microsoft/microsoft-graph. I sent a MR and then went the rabbit hole adding multiple new MR across many microsoft libraries doing the same thing – fixing compatibility with PHP 8.4. I specifically opened this MR to allow installing php-http/promise 1.3.0, because this library depends on it and at the time, the 1.3 version was compatible with PHP 8.4. After submitting a patch, the PHPStan tests started to failing. It was then, when I realized, why this library is locked to php-http/promise 1.2, not allowing installing 1.3. Making own promises started with your comment from 7th April. I tried to implement the very own Promise classes, but run into errors with PHPStan, I couldn't solve. I agree, that locking this library to the 1.2 is a bad situation and agree, that making own Promises would solve it properly. I just can not agree with the claim, that this PR was about adding own Promises to the library. If you still think, we should continue trying adding own Promises to the library, so we could unlock the version constraint, I could try to revisit the PHPStan errors and try to figure out, if the problem still persists (after all, it is more than a half year later - meaning I have another half a year more experience with PHPStan and there has been multiple new versions of PHPStan since then). |
|
Thank you for the additional information.
Sorry, I jumped from the conclusion of "we need to unpin the version, and to do so implement our own promises definitions" to "this is what this PR meant to do". When in fact adding promises in this PR was just a mean to get 8.4 support, which was better achieved by patching the promise dependency. If we focus on the original issue (PHP 8.4 getting a compat warning during install)
So unless another version is being pulled by the consuming project, or a third party dependency of the packages listed above, the end user should not receive a warning about PHP 8.4 compatibility anymore. Could you please confirm that? As for the risk posed by having a version pinned, which would lead to conflicts in consumer projects, or version 1.2.X of promises getting stale/posing a security risk, this is something that can be addressed at a later stage. Of course if you want to get ahead of the curve here and finalize this PR, which contains most of what's needed to address this risk, we'll be more than happy to take the contribution in. Does that make sense? |

php-http/promise version 1.3.1 fixed compatibility issues with PHP 8.4. This pull request updates composer.json to allow installing this version of the php-http/promise library