Skip to content

Commit fe7dfe4

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: Add missing version in versionadded [Validator] Mention `exactly` option for Length constraint [HttpClient] Add withOptions() to HttplugClient and Psr18Client
2 parents a6228f8 + a4c08b8 commit fe7dfe4

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

http_client.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,27 @@ Now you can make HTTP requests with the PSR-18 client as follows:
14401440
14411441
$content = json_decode($response->getBody()->getContents(), true);
14421442
1443+
You can also pass a set of default options to your client thanks to the
1444+
``Psr18Client::withOptions()`` method::
1445+
1446+
use Symfony\Component\HttpClient\Psr18Client;
1447+
1448+
$client = (new Psr18Client())
1449+
->withOptions([
1450+
'base_uri' => 'https://symfony.com',
1451+
'headers' => [
1452+
'Accept' => 'application/json',
1453+
],
1454+
]);
1455+
1456+
$request = $client->createRequest('GET', '/versions.json');
1457+
1458+
// ...
1459+
1460+
.. versionadded:: 6.2
1461+
1462+
The ``Psr18Client::withOptions()`` method was introduced in Symfony 6.2.
1463+
14431464
HTTPlug
14441465
~~~~~~~
14451466

@@ -1528,6 +1549,24 @@ Then you're ready to go::
15281549
// wait for all remaining promises to resolve
15291550
$httpClient->wait();
15301551

1552+
You can also pass a set of default options to your client thanks to the
1553+
``HttplugClient::withOptions()`` method::
1554+
1555+
use Psr\Http\Message\ResponseInterface;
1556+
use Symfony\Component\HttpClient\HttplugClient;
1557+
1558+
$httpClient = (new HttplugClient())
1559+
->withOptions([
1560+
'base_uri' => 'https://my.api.com',
1561+
]);
1562+
$request = $httpClient->createRequest('GET', '/');
1563+
1564+
// ...
1565+
1566+
.. versionadded:: 6.2
1567+
1568+
The ``HttplugClient::withOptions()`` method was introduced in Symfony 6.2.
1569+
15311570
Native PHP Streams
15321571
~~~~~~~~~~~~~~~~~~
15331572

reference/constraints/Length.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,25 @@ Parameter Description
123123
``{{ value }}`` The current (invalid) value
124124
================= ============================================================
125125

126+
exactly
127+
~~~~~~~
128+
129+
**type**: ``integer``
130+
131+
This option is the exact length value. Validation will fail if
132+
the given value's length is not **exactly** equal to this value.
133+
134+
.. note::
135+
136+
This option is the one being set by default when using the Length constraint
137+
without passing any named argument to it. This means that for example,
138+
``@Assert\Length(20)`` and ``@Assert\Length(exactly=20)`` are equivalent, as
139+
well as ``#[Assert\Length(20)]`` and ``#[Assert\Length(exactly: 20)]``.
140+
141+
.. versionadded:: 5.2
142+
143+
The named argument ``exactly`` was introduced in Symfony 5.2.
144+
126145
exactMessage
127146
~~~~~~~~~~~~
128147

0 commit comments

Comments
 (0)