Skip to content

Commit

Permalink
Add generic types to traversable implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Nov 3, 2021
1 parent 714059c commit b72eab3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions HttplugClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ final class HttplugClient implements HttplugInterface, HttpAsyncClient, RequestF
private $client;
private $responseFactory;
private $streamFactory;

/**
* @var \SplObjectStorage<ResponseInterface, array{RequestInterface, Promise}>|null
*/
private $promisePool;

private $waitLoop;

public function __construct(HttpClientInterface $client = null, ResponseFactoryInterface $responseFactory = null, StreamFactoryInterface $streamFactory = null)
Expand Down
5 changes: 5 additions & 0 deletions Internal/HttplugWaitLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace Symfony\Component\HttpClient\Internal;

use Http\Client\Exception\NetworkException;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface as Psr7RequestInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface as Psr7ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand All @@ -33,6 +35,9 @@ final class HttplugWaitLoop
private $responseFactory;
private $streamFactory;

/**
* @param \SplObjectStorage<ResponseInterface, array{Psr7RequestInterface, Promise}>|null $promisePool
*/
public function __construct(HttpClientInterface $client, ?\SplObjectStorage $promisePool, ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory)
{
$this->client = $client;
Expand Down
6 changes: 6 additions & 0 deletions Response/AsyncResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ public static function stream(iterable $responses, float $timeout = null, string
}
}

/**
* @param \SplObjectStorage<ResponseInterface, AsyncResponse>|null $asyncMap
*/
private static function passthru(HttpClientInterface $client, self $r, ChunkInterface $chunk, \SplObjectStorage $asyncMap = null): \Generator
{
$r->stream = null;
Expand All @@ -332,6 +335,9 @@ private static function passthru(HttpClientInterface $client, self $r, ChunkInte
yield from self::passthruStream($response, $r, null, $asyncMap);
}

/**
* @param \SplObjectStorage<ResponseInterface, AsyncResponse>|null $asyncMap
*/
private static function passthruStream(ResponseInterface $response, self $r, ?ChunkInterface $chunk, ?\SplObjectStorage $asyncMap): \Generator
{
while (true) {
Expand Down
2 changes: 2 additions & 0 deletions Response/TransportResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ private function doDestruct()
/**
* Implements an event loop based on a buffer activity queue.
*
* @param iterable<array-key, self> $responses
*
* @internal
*/
public static function stream(iterable $responses, float $timeout = null): \Generator
Expand Down

0 comments on commit b72eab3

Please sign in to comment.