ackintosh / ganesha

:elephant: A Circuit Breaker pattern implementation for PHP applications.
https://ackintosh.github.io/ganesha/
MIT License
585 stars 42 forks source link

Upgrade Guzzle Promises Function API to Static API #104

Closed DimionX closed 1 year ago

DimionX commented 1 year ago

Guzzle Promises: A static API was first introduced in 1.4.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0.

https://github.com/guzzle/promises#upgrading-from-function-api

coveralls commented 1 year ago

Coverage Status

coverage: 91.479% (+91.5%) from 0.0% when pulling 2b7d59b3cea03d2a02028ccb4842a45b42feb111 on DimionX:patch-1 into add74da3a7b471e48ec8f171d25ca4903c308103 on ackintosh:master.

ackintosh commented 1 year ago

@DimionX Thank you for this PR!


The tests with --prefer-lowest have failed with the error:

https://github.com/ackintosh/ganesha/actions/runs/5200076716/jobs/9482744646?pr=104

1) Ackintosh\Ganesha\GuzzleMiddlewareTest::reject Failed asserting that exception of type "Error" matches expected exception "Ackintosh\Ganesha\Exception\RejectedException". Message was: "Class "GuzzleHttp\Promise\Create" not found"

This tells us that we should support the both promise_for and Create::promiseFor. I think it has been done with the code like:

if (class_exists('\GuzzleHttp\Promise\Create')) {
    return call_user_func('\GuzzleHttp\Promise\Create::rejectionFor', ...);
} else {
    return call_user_func('\GuzzleHttp\Promise\rejection_for', ...);
}

(this is just for example, there may exist a cleaner way)

ackintosh commented 1 year ago

I will add commits to this Pull Request to fix the error with --prefer-lowest. Please give me a little time.

ackintosh commented 1 year ago

@DimionX I have updated your Pull Request to fix an error detected by CI, now the tests on CI have passed. Could you try the updated one to check if the problem you reported has been fixed on your environment?

DimionX commented 1 year ago

@ackintosh Thanks! The problem is solved, now everything is fine

ackintosh commented 1 year ago

@DimionX This PR has been released as v3.1.1. 🎉 Thank you for your contribution! https://github.com/ackintosh/ganesha/releases/tag/3.1.1