Skip to content

Commit 9da775d

Browse files
committed
Added deprecation notice
1 parent 0d520e8 commit 9da775d

File tree

1 file changed

+58
-52
lines changed

1 file changed

+58
-52
lines changed

discovery.rst

Lines changed: 58 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ Currently available discovery services:
1010

1111
- HTTP Client Discovery
1212
- HTTP Async Client Discovery
13-
- PSR-7 Message Factory Discovery
14-
- PSR-7 URI Factory Discovery
15-
- PSR-7 Stream Factory Discovery
1613
- PSR-17 Factory Discovery
17-
- PSR-18 Client Discovery
14+
- PSR-18 HTTP Client Discovery
1815
- Mock Client Discovery (not enabled by default)
16+
- PSR-7 Message Factory Discovery (deprecated)
17+
- PSR-7 URI Factory Discovery (deprecated)
18+
- PSR-7 Stream Factory Discovery (deprecated)
1919

2020
The principle is always the same: you call the static ``find`` method on the discovery service if no explicit
2121
implementation was specified. The discovery service will try to locate a suitable implementation.
@@ -187,101 +187,107 @@ This type of discovery finds a HTTP asynchronous Client implementation::
187187
}
188188
}
189189

190-
PSR-7 Message Factory Discovery
191-
-------------------------------
190+
PSR-17 Factory Discovery
191+
------------------------
192192

193-
This type of discovery finds a :ref:`message-factory` for a PSR-7_ Message
194-
implementation::
193+
This type of discovery finds a factory for a PSR-17_ implementation::
195194

196-
use Http\Message\MessageFactory;
197-
use Http\Discovery\MessageFactoryDiscovery;
195+
use Psr\Http\Message\RequestFactoryInterface;
196+
use Psr\Http\Message\ResponseFactoryInterface;
197+
use Http\Discovery\Psr17FactoryDiscovery;
198198

199199
class MyClass
200200
{
201201
/**
202-
* @var MessageFactory
202+
* @var RequestFactoryInterface
203203
*/
204-
private $messageFactory;
204+
private $requestFactory;
205205

206206
/**
207-
* @param MessageFactory|null $messageFactory to create PSR-7 requests.
207+
* @var ResponseFactoryInterface
208208
*/
209-
public function __construct(MessageFactory $messageFactory = null)
209+
private $responseFactory;
210+
211+
public function __construct(RequestFactoryInterface $requestFactory = null, ResponseFactoryInterface $responseFactory = null)
210212
{
211-
$this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find();
213+
$this->requestFactory = $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory();
214+
$this->responseFactory = $responseFactory ?: Psr17FactoryDiscovery::findResponseFactory();
212215
}
213216
}
214217

215-
PSR-7 URI Factory Discovery
216-
---------------------------
218+
PSR-18 Client Discovery
219+
-----------------------
217220

218-
This type of discovery finds a URI factory for a PSR-7_ URI implementation::
221+
This type of discovery finds a PSR-18_ HTTP Client implementation::
219222

220-
use Http\Message\UriFactory;
221-
use Http\Discovery\UriFactoryDiscovery;
223+
use Psr\Http\Client\ClientInterface;
224+
use Http\Discovery\Psr18ClientDiscovery;
222225

223226
class MyClass
224227
{
225228
/**
226-
* @var UriFactory
229+
* @var ClientInterface
227230
*/
228-
private $uriFactory;
231+
private $httpClient;
229232

230-
/**
231-
* @param UriFactory|null $uriFactory to create UriInterface instances from strings.
232-
*/
233-
public function __construct(UriFactory $uriFactory = null)
233+
public function __construct(ClientInterface $httpClient = null)
234234
{
235-
$this->uriFactory = $uriFactory ?: UriFactoryDiscovery::find();
235+
$this->httpClient = $httpClient ?: Psr18ClientDiscovery::find();
236236
}
237237
}
238-
239-
PSR-17 Factory Discovery
240-
------------------------
241238

242-
This type of discovery finds a factory for a PSR-17_ implementation::
239+
PSR-7 Message Factory Discovery
240+
-------------------------------
243241

244-
use Psr\Http\Message\RequestFactoryInterface;
245-
use Psr\Http\Message\ResponseFactoryInterface;
246-
use Http\Discovery\Psr17FactoryDiscovery;
242+
.. versionadded:: 1.6
243+
This is deprecated and will be removed in 2.0. Consider using PSR-17 Factory Discovery.
244+
245+
This type of discovery finds a :ref:`message-factory` for a PSR-7_ Message
246+
implementation::
247+
248+
use Http\Message\MessageFactory;
249+
use Http\Discovery\MessageFactoryDiscovery;
247250

248251
class MyClass
249252
{
250253
/**
251-
* @var RequestFactoryInterface
254+
* @var MessageFactory
252255
*/
253-
private $requestFactory;
254-
256+
private $messageFactory;
257+
255258
/**
256-
* @var ResponseFactoryInterface
259+
* @param MessageFactory|null $messageFactory to create PSR-7 requests.
257260
*/
258-
private $responseFactory;
259-
260-
public function __construct(RequestFactoryInterface $requestFactory = null, ResponseFactoryInterface $responseFactory = null)
261+
public function __construct(MessageFactory $messageFactory = null)
261262
{
262-
$this->requestFactory = $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory();
263-
$this->responseFactory = $responseFactory ?: Psr17FactoryDiscovery::findResponseFactory();
263+
$this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find();
264264
}
265265
}
266266

267-
PSR-18 Client Discovery
268-
-----------------------
267+
PSR-7 URI Factory Discovery
268+
---------------------------
269269

270-
This type of discovery finds a PSR-18_ HTTP Client implementation::
270+
.. versionadded:: 1.6
271+
This is deprecated and will be removed in 2.0. Consider using PSR-17 Factory Discovery.
271272

272-
use Psr\Http\Client\ClientInterface;
273-
use Http\Discovery\Psr18ClientDiscovery;
273+
This type of discovery finds a URI factory for a PSR-7_ URI implementation::
274+
275+
use Http\Message\UriFactory;
276+
use Http\Discovery\UriFactoryDiscovery;
274277

275278
class MyClass
276279
{
277280
/**
278-
* @var ClientInterface
281+
* @var UriFactory
279282
*/
280-
private $httpClient;
283+
private $uriFactory;
281284

282-
public function __construct(ClientInterface $httpClient = null)
285+
/**
286+
* @param UriFactory|null $uriFactory to create UriInterface instances from strings.
287+
*/
288+
public function __construct(UriFactory $uriFactory = null)
283289
{
284-
$this->httpClient = $httpClient ?: Psr18ClientDiscovery::find();
290+
$this->uriFactory = $uriFactory ?: UriFactoryDiscovery::find();
285291
}
286292
}
287293

0 commit comments

Comments
 (0)