Skip to content

Commit ad116ef

Browse files
committed
deprecate setLogger() methods of decorating clients
1 parent 511095d commit ad116ef

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CHANGELOG
88
* Allow mocking `start_time` info in `MockResponse`
99
* Add `MockResponse::fromFile()` and `JsonMockResponse::fromFile()` methods to help using fixtures files
1010
* Add `ThrottlingHttpClient` to enable limiting the number of requests within a certain period
11+
* Deprecate the `setLogger()` methods of the `NoPrivateNetworkHttpClient`, `TraceableHttpClient` and `ScopingHttpClient` classes, configure the logger of the wrapped clients directly instead
1112

1213
7.0
1314
---

NoPrivateNetworkHttpClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,13 @@ public function stream(ResponseInterface|iterable $responses, ?float $timeout =
7777
return $this->client->stream($responses, $timeout);
7878
}
7979

80+
/**
81+
* @deprecated since Symfony 7.1, configure the logger on the wrapper HTTP client directly instead
82+
*/
8083
public function setLogger(LoggerInterface $logger): void
8184
{
85+
trigger_deprecation('symfony/http-client', '7.1', 'Configure the logger on the wrapper HTTP client directly instead.');
86+
8287
if ($this->client instanceof LoggerAwareInterface) {
8388
$this->client->setLogger($logger);
8489
}

ScopingHttpClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,13 @@ public function reset(): void
100100
}
101101
}
102102

103+
/**
104+
* @deprecated since Symfony 7.1, configure the logger on the wrapper HTTP client directly instead
105+
*/
103106
public function setLogger(LoggerInterface $logger): void
104107
{
108+
trigger_deprecation('symfony/http-client', '7.1', 'Configure the logger on the wrapper HTTP client directly instead.');
109+
105110
if ($this->client instanceof LoggerAwareInterface) {
106111
$this->client->setLogger($logger);
107112
}

TraceableHttpClient.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ public function reset(): void
8989
$this->tracedRequests->exchangeArray([]);
9090
}
9191

92+
/**
93+
* @deprecated since Symfony 7.1, configure the logger on the wrapper HTTP client directly instead
94+
*/
9295
public function setLogger(LoggerInterface $logger): void
9396
{
97+
trigger_deprecation('symfony/http-client', '7.1', 'Configure the logger on the wrapper HTTP client directly instead.');
98+
9499
if ($this->client instanceof LoggerAwareInterface) {
95100
$this->client->setLogger($logger);
96101
}

0 commit comments

Comments
 (0)