Skip to content

Commit 91a3dc0

Browse files
committed
Declare parameter and return types
1 parent 4d1ca68 commit 91a3dc0

26 files changed

+137
-279
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
1818
- Changed the type of `httplug.client.default` to `ClientInterface` instead of `HttpClient`
1919
- Removed the `DummyClient` interface
2020
- Removed the `Http\Client\HttpClient` alias use the `Psr\Http\Client\ClientInterface` typehint in your services for autowiring.
21+
- Added return type declaration to `Http\HttplugBundle\ClientFactory\ClientFactory::createClient`
2122

2223
# Version 1
2324

src/ClientFactory/AutoDiscoveryFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Http\HttplugBundle\ClientFactory;
66

77
use Http\Discovery\Psr18ClientDiscovery;
8+
use Psr\Http\Client\ClientInterface;
89

910
/**
1011
* Use auto discovery to find a HTTP client.
@@ -15,7 +16,7 @@
1516
*/
1617
class AutoDiscoveryFactory implements ClientFactory
1718
{
18-
public function createClient(array $config = [])
19+
public function createClient(array $config = []): ClientInterface
1920
{
2021
return Psr18ClientDiscovery::find();
2122
}

src/ClientFactory/BuzzFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Http\HttplugBundle\ClientFactory;
66

77
use Buzz\Client\FileGetContents;
8+
use Psr\Http\Client\ClientInterface;
89
use Psr\Http\Message\ResponseFactoryInterface;
910
use Symfony\Component\OptionsResolver\OptionsResolver;
1011

@@ -19,7 +20,7 @@ public function __construct(private readonly ResponseFactoryInterface $responseF
1920
{
2021
}
2122

22-
public function createClient(array $config = [])
23+
public function createClient(array $config = []): ClientInterface
2324
{
2425
if (!class_exists('Buzz\Client\FileGetContents')) {
2526
throw new \LogicException('To use the Buzz you need to install the "kriswallsmith/buzz" package.');
@@ -31,7 +32,7 @@ public function createClient(array $config = [])
3132
/**
3233
* Get options to configure the Buzz client.
3334
*/
34-
private function getOptions(array $config = [])
35+
private function getOptions(array $config = []): array
3536
{
3637
$resolver = new OptionsResolver();
3738

src/ClientFactory/ClientFactory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ interface ClientFactory
1313
{
1414
/**
1515
* Input an array of configuration to be able to create a ClientInterface.
16-
*
17-
* @return ClientInterface
1816
*/
19-
public function createClient(array $config = []);
17+
public function createClient(array $config = []): ClientInterface;
2018
}

src/ClientFactory/CurlFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Http\HttplugBundle\ClientFactory;
66

77
use Http\Client\Curl\Client;
8+
use Psr\Http\Client\ClientInterface;
89
use Psr\Http\Message\ResponseFactoryInterface;
910
use Psr\Http\Message\StreamFactoryInterface;
1011

@@ -21,7 +22,7 @@ public function __construct(
2122
) {
2223
}
2324

24-
public function createClient(array $config = [])
25+
public function createClient(array $config = []): ClientInterface
2526
{
2627
if (!class_exists('Http\Client\Curl\Client')) {
2728
throw new \LogicException('To use the Curl client you need to install the "php-http/curl-client" package.');

src/ClientFactory/Guzzle6Factory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Http\HttplugBundle\ClientFactory;
66

77
use Http\Adapter\Guzzle6\Client;
8+
use Psr\Http\Client\ClientInterface;
89

910
/**
1011
* @author Tobias Nyholm <[email protected]>
@@ -13,7 +14,7 @@
1314
*/
1415
class Guzzle6Factory implements ClientFactory
1516
{
16-
public function createClient(array $config = [])
17+
public function createClient(array $config = []): ClientInterface
1718
{
1819
if (!class_exists('Http\Adapter\Guzzle6\Client')) {
1920
throw new \LogicException('To use the Guzzle6 adapter you need to install the "php-http/guzzle6-adapter" package.');

src/ClientFactory/Guzzle7Factory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Http\HttplugBundle\ClientFactory;
66

77
use Http\Adapter\Guzzle7\Client;
8+
use Psr\Http\Client\ClientInterface;
89

910
/**
1011
* @author Tobias Nyholm <[email protected]>
@@ -13,7 +14,7 @@
1314
*/
1415
class Guzzle7Factory implements ClientFactory
1516
{
16-
public function createClient(array $config = [])
17+
public function createClient(array $config = []): ClientInterface
1718
{
1819
if (!class_exists('Http\Adapter\Guzzle7\Client')) {
1920
throw new \LogicException('To use the Guzzle7 adapter you need to install the "php-http/guzzle7-adapter" package.');

src/ClientFactory/MockFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class MockFactory implements ClientFactory
1919
*
2020
* Note that this can be any client, not only a mock client.
2121
*/
22-
public function setClient(ClientInterface $client)
22+
public function setClient(ClientInterface $client): void
2323
{
2424
$this->client = $client;
2525
}
2626

27-
public function createClient(array $config = [])
27+
public function createClient(array $config = []): ClientInterface
2828
{
2929
if (!class_exists(Client::class)) {
3030
throw new \LogicException('To use the mock adapter you need to install the "php-http/mock-client" package.');

src/ClientFactory/ReactFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Http\HttplugBundle\ClientFactory;
66

77
use Http\Adapter\React\Client;
8+
use Psr\Http\Client\ClientInterface;
89

910
/**
1011
* @author Tobias Nyholm <[email protected]>
@@ -13,7 +14,7 @@
1314
*/
1415
class ReactFactory implements ClientFactory
1516
{
16-
public function createClient(array $config = [])
17+
public function createClient(array $config = []): ClientInterface
1718
{
1819
if (!class_exists('Http\Adapter\React\Client')) {
1920
throw new \LogicException('To use the React adapter you need to install the "php-http/react-adapter" package.');

src/ClientFactory/SocketFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Http\HttplugBundle\ClientFactory;
66

77
use Http\Client\Socket\Client;
8+
use Psr\Http\Client\ClientInterface;
89

910
/**
1011
* @author Tobias Nyholm <[email protected]>
@@ -13,7 +14,7 @@
1314
*/
1415
class SocketFactory implements ClientFactory
1516
{
16-
public function createClient(array $config = [])
17+
public function createClient(array $config = []): ClientInterface
1718
{
1819
if (!class_exists('Http\Client\Socket\Client')) {
1920
throw new \LogicException('To use the Socket client you need to install the "php-http/socket-client" package.');

0 commit comments

Comments
 (0)