-
Notifications
You must be signed in to change notification settings - Fork 9
Upgrade HTTPlug from Legacy to PSR 17/18 Discovery Factories #67
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
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.
Looks like the install instructions aren't working aymore if php-http/guzzle7-adapter
needs to be used. Can you adjust that too?
private $plugins = []; | ||
|
||
public function __construct(ClientInterface $httpClient = null, RequestFactory $requestFactory = null) | ||
public function __construct(ClientInterface $httpClient = null, RequestFactoryInterface $requestFactory = null) |
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.
This is a braking change. Any way we can introduce this in a none breaking way e.g. have the method accept RequestFactory|RequestFactoryInterface
? Otherwise, we'd have to release this as a new major version, where we should probably remove several of the deprecated methods too but would prefer adding this none breaking first with maybe a deprecation message.
It also works with However, HTTPlug's I don't think there's any way to do this without a breaking change. |
We could just not type-hint the argument, and have runtime variable checks instead? |
Using PHPDoc instead of a typehint sounds good. Can then using something like https://packagist.org/packages/doctrine/deprecations or https://packagist.org/packages/symfony/deprecation-contracts to trigger a deprecation if the old service is passed. |
976531e
to
9a9e049
Compare
class HttpPluginClientBuilderTest extends TestCase | ||
{ | ||
/** @dataProvider provideRequestFactories */ | ||
public function testRequestFactory(?object $factory, ?string $expectedException): void |
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.
Can this be two different tests? One that throws the exception and one that doesn't? Makes it easier to see what is actually necessary for the test case with the exception
* The concrete implementation of the RequestMatcher interface does not allow matching on | ||
* headers, which we need to test to ensure both legacy and PSR17 implementations work. | ||
*/ | ||
protected function matchRequestIncludingHeaders(): RequestMatcherInterface |
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.
protected function matchRequestIncludingHeaders(): RequestMatcherInterface | |
private function matchRequestIncludingHeaders(): RequestMatcherInterface |
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.
Just noticed this PR and it seems like we never finish it. @zanbaldwin do you remember what is still to do here? If I update one of my projects to use your branch then running
$token = $client->tokens()->create([
'description' => 'Team-Token ' . time(),
'access' => 'read',
'accessToAllPackages' => true,
]);
errors with
Uncaught RuntimeException: Cannot create request: A stream factory is required to create a request with a non-empty string body. in vendor/php-http/client-common/src/HttpMethodsClient.php:135
So there is definitely still something off with the HttpPluginClientBuilder when we create the HttpMethodsClient
Note: Have yet to check lowest supported PHP version for this. Will just check result of CI.
Tested With
composer.json
index.php