Skip to content

We are force to require php-http/message-factory #64

Closed
@benjaminmal

Description

@benjaminmal

PHP version: 8.1.11

Description
Since 1.5.2 and #62, the mock client doesn't work anymore and all my checks fail with:

Http\Discovery\NotFoundException : No php-http message factories found. Note that the php-http message factories are deprecated in favor of the PSR-17 message factories. To use the legacy Guzzle, Diactoros or Slim Framework factories of php-http, install php-http/message and php-http/message-factory and the chosen message implementation.

Since the library uses deprecated Http\Discovery\MessageFactoryDiscovery::find() from php-http/discovery in Http\Mock\Client::__construct() and neither php-http/discovery and php-http/mock-client require php-http/message-factory, Http\Discovery\MessageFactoryDiscovery::find() will always throws the exception Http\Discovery\NotFoundException.

So we are force to require php-http/message-factory to fix the issue. Isn't it a BC break? Not sure if this belongs here or in php-http/discovery...

How to reproduce

// Note here the absence of `$responseFactory` in the contructor.
new Http\Mock\Client();

composer.json:

{
// ...
    "require-dev": {
        "php-http/discovery": "^1.18.1",
        "php-http/mock-client": "^1.5.2"
    }
}

Possible Solution

  1. Revert Remove dependency on php-http/message-factory #62.
  2. Stop using deprecated MessageFactoryDiscovery::find() in next versions.
  3. Unrevert Remove dependency on php-http/message-factory #62.

Additional context
No sure why your tests aren't failing, I guess here, the client is always initialized with $responseFactory which, in our case, ignores MessageFactoryDiscovery::find().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions