-
Notifications
You must be signed in to change notification settings - Fork 1
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
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-completion I'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...) |
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