Skip to content

Commit

Permalink
Remove unneeded loop argument from HttpClient: Client, Request, Response
Browse files Browse the repository at this point in the history
  • Loading branch information
igorw committed Dec 4, 2013
1 parent 835e440 commit bef4d8c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
6 changes: 2 additions & 4 deletions Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

class Client
{
private $loop;
private $connectionManager;
private $secureConnectionManager;

public function __construct(LoopInterface $loop, ConnectorInterface $connector, ConnectorInterface $secureConnector)
public function __construct(ConnectorInterface $connector, ConnectorInterface $secureConnector)
{
$this->loop = $loop;
$this->connector = $connector;
$this->secureConnector = $secureConnector;
}
Expand All @@ -23,7 +21,7 @@ public function request($method, $url, array $headers = array())
{
$requestData = new RequestData($method, $url, $headers);
$connectionManager = $this->getConnectorForScheme($requestData->getScheme());
return new Request($this->loop, $connectionManager, $requestData);
return new Request($connectionManager, $requestData);

}

Expand Down
2 changes: 1 addition & 1 deletion Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function create(LoopInterface $loop, Resolver $resolver)
{
$connector = new Connector($loop, $resolver);
$secureConnector = new SecureConnector($connector, $loop);
return new Client($loop, $connector, $secureConnector);
return new Client($connector, $secureConnector);
}
}

8 changes: 2 additions & 6 deletions Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class Request extends EventEmitter implements WritableStreamInterface
const STATE_HEAD_WRITTEN = 2;
const STATE_END = 3;

private $loop;
private $connector;
private $requestData;

Expand All @@ -32,9 +31,8 @@ class Request extends EventEmitter implements WritableStreamInterface
private $response;
private $state = self::STATE_INIT;

public function __construct(LoopInterface $loop, ConnectorInterface $connector, RequestData $requestData)
public function __construct(ConnectorInterface $connector, RequestData $requestData)
{
$this->loop = $loop;
$this->connector = $connector;
$this->requestData = $requestData;
}
Expand Down Expand Up @@ -227,12 +225,10 @@ public function setResponseFactory($factory)
public function getResponseFactory()
{
if (null === $factory = $this->responseFactory) {
$loop = $this->loop;
$stream = $this->stream;

$factory = function ($protocol, $version, $code, $reasonPhrase, $headers) use ($loop, $stream) {
$factory = function ($protocol, $version, $code, $reasonPhrase, $headers) use ($stream) {
return new Response(
$loop,
$stream,
$protocol,
$version,
Expand Down
4 changes: 1 addition & 3 deletions Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class Response extends EventEmitter implements ReadableStreamInterface
{
private $loop;
private $stream;
private $protocol;
private $version;
Expand All @@ -20,9 +19,8 @@ class Response extends EventEmitter implements ReadableStreamInterface
private $headers;
private $readable = true;

public function __construct(LoopInterface $loop, Stream $stream, $protocol, $version, $code, $reasonPhrase, $headers)
public function __construct(Stream $stream, $protocol, $version, $code, $reasonPhrase, $headers)
{
$this->loop = $loop;
$this->stream = $stream;
$this->protocol = $protocol;
$this->version = $version;
Expand Down

0 comments on commit bef4d8c

Please sign in to comment.