Skip to content

Conversation

@Art4
Copy link
Collaborator

@Art4 Art4 commented Sep 14, 2023

In #257 we introduced the new Psr18Client, based on a PSR-18 client and PSR-17 factories.

Some month ago I noticed that I required a Psr\Http\Message\ServerRequestFactoryInterface, but we only need a Psr\Http\Message\RequestFactoryInterface. This shouldn't be a problem, because all PSR-18 clients are working with Psr\Http\Message\RequestInterface implementations and ServerRequestInterface is extending the RequestInterface.

However this PR will fix this by allowing a Psr\Http\Message\RequestFactoryInterface implementation in the Psr18Client. Providing a Psr\Http\Message\ServerRequestFactoryInterface will also work but is deprecated and will trigger a deprecation warning. In the next major release we can remove the support for Psr\Http\Message\ServerRequestFactoryInterface completely.

@Art4 Art4 added the bug label Sep 14, 2023
@Art4 Art4 requested a review from kbsali September 14, 2023 14:43
@Art4 Art4 changed the title Replace serverrequestfactory with requestfactory Replace ServerRequestFactory with RequestFactory Sep 14, 2023
@kbsali kbsali merged commit d751116 into kbsali:v2.x Sep 14, 2023
@Art4 Art4 deleted the replace-serverrequestfactory-with-requestfactory branch September 14, 2023 20:57

### Added

- Allow `Psr\Http\Message\ServerRequestFactoryInterface` as Argument #2 ($requestFactory) in `Redmine\Client\Psr18Client::__construct()`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-- Allow `Psr\Http\Message\ServerRequestFactoryInterface` as Argument #2 ($requestFactory) in `Redmine\Client\Psr18Client::__construct()`
+- Allow `Psr\Http\Message\RequestFactoryInterface` as Argument #2 ($requestFactory) in `Redmine\Client\Psr18Client::__construct()`

string $apikeyOrUsername,
string $password = null
) {
if ($requestFactory instanceof ServerRequestFactoryInterface) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also check if $requestFactory is not an instance of RequestFactoryInterface already. \GuzzleHttp\Psr7\HttpFactory from the README example implements both interfaces.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants