Skip to content

Added a way to be forward compatible with version 2.0 #132

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

Merged
merged 6 commits into from
Dec 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Plugin/VersionBridgePlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Http\Client\Common\Plugin;

use Psr\Http\Message\RequestInterface;

/**
* A plugin that helps you migrate from php-http/client-common 1.x to 2.x. This
* will also help you to support PHP5 at the same time you support 2.x.
*
* @author Tobias Nyholm <[email protected]>
*/
trait VersionBridgePlugin
{
abstract protected function doHandleRequest(RequestInterface $request, callable $next, callable $first);

public function handleRequest(RequestInterface $request, callable $next, callable $first)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this missing the return type hint?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is for master (ie 1.9.0).

Here we should be compatible with httplug 1. Check #133 for httplug 2.0.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I didn't see that PR yet. 👍

{
return $this->doHandleRequest($request, $next, $first);
}
}
21 changes: 21 additions & 0 deletions src/VersionBridgeClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Http\Client\Common;

use Psr\Http\Message\RequestInterface;

/**
* A client that helps you migrate from php-http/httplug 1.x to 2.x. This
* will also help you to support PHP5 at the same time you support 2.x.
*
* @author Tobias Nyholm <[email protected]>
*/
trait VersionBridgeClient
{
abstract protected function doSendRequest(RequestInterface $request);

public function sendRequest(RequestInterface $request)
Copy link
Member

Choose a reason for hiding this comment

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

same here

{
return $this->doSendRequest($request);
}
}