-
Notifications
You must be signed in to change notification settings - Fork 39
Adding PSR package #128
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
Adding PSR package #128
Changes from 2 commits
af00486
cbc903a
de1c010
307c7fe
58d0ada
7d9f4ec
f217324
310b13f
b45b737
f5b7e91
b1f4ee6
1b29077
b16582b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,6 @@ cache: | |
- $HOME/.composer/cache/files | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
* | ||
* @author Márk Sági-Kazár <[email protected]> | ||
*/ | ||
interface Exception | ||
interface Exception extends \Throwable | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ public function __construct( | |
* | ||
* @return ResponseInterface | ||
*/ | ||
public function getResponse() | ||
public function getResponse(): ResponseInterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a BC break: https://3v4l.org/LOOiv Is this something we want to avoid in this update to make it as smooth as possible? |
||
{ | ||
return $this->response; | ||
} | ||
|
@@ -60,7 +60,7 @@ public static function create( | |
RequestInterface $request, | ||
ResponseInterface $response, | ||
\Exception $previous = null | ||
) { | ||
): self { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
$message = sprintf( | ||
'[url] %s [http method] %s [status code] %s [reason phrase] %s', | ||
$request->getRequestTarget(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,5 @@ interface HttpAsyncClient | |
* | ||
* @throws \Exception If processing the request is impossible (eg. bad configuration). | ||
*/ | ||
public function sendAsyncRequest(RequestInterface $request); | ||
public function sendAsyncRequest(RequestInterface $request): Promise; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this problem when we are doing the same update for the Async HTTP client PSR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there needs to be a new major version anyways when a promise PSR is out, so we might as well do this change now to make it more explicit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to be more permissive in the async implementation, to allow every value and exception in our promise, this would be better, after years of use it was a mistake to reduce the scope IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair, so what do you suggest? I've written There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, it's in another package, we would need to update the promise lib and then allow 2.0 here, but maybe it will not be bc break for this package, so nothing to change here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (We would still need to release a 2.1 with the package dependency upgrade to allow 1.0 || 2.0 for the promise lib) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact what do you think of using https://amphp.org/amp/promises/ interface ? there is an adapter for react and we could drop support of async for guzzle (as it's not really async in fact, it's only parallel) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm.. Im not sure at all... On one hand: Do as little change as possible. That will make it easier for everyone. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how soon is a PSR Promise to be expected? i would assume that will take a couple of years, so if its a clear and good upgrade, i would be ok to have version 2 do something different. then again, to make the PSR move for sync http client as smooth as possible, its maybe better to not limit ourselves here and avoid a BC break |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace Http\Client; | ||
|
||
use Http\HttplugBundle\Tests\Unit\Collector\ClientInterface; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
|
@@ -12,7 +13,7 @@ | |
* @author Márk Sági-Kazár <[email protected]> | ||
* @author David Buchmann <[email protected]> | ||
*/ | ||
interface HttpClient | ||
interface HttpClient extends ClientInterface | ||
{ | ||
/** | ||
* Sends a PSR-7 request. | ||
|
@@ -24,5 +25,5 @@ interface HttpClient | |
* @throws \Http\Client\Exception If an error happens during processing the request. | ||
* @throws \Exception If processing the request is impossible (eg. bad configuration). | ||
*/ | ||
public function sendRequest(RequestInterface $request); | ||
public function sendRequest(RequestInterface $request): ResponseInterface; | ||
} |
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.
in our projects we started the rule that when
@return
just repeats the return type declaration and has no valuable information, we remove the@return
line.(in that vein "Returns the response" is redundant to the method name. either there is more details to explain or there should be no comment...)
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.
I agree. 👍
I will remove these redundant comments.