Skip to content

Commit bcdebc1

Browse files
committed
Finish Deprecation Notices in HttpPluginClientBuilder
1 parent 9a9e049 commit bcdebc1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"php-http/discovery": "^1.0",
1919
"psr/http-client-implementation": "^1.0",
2020
"php-http/message-factory": "^1.0",
21-
"psr/http-message-implementation": "^1.0",
22-
"symfony/deprecation-contracts": "^2.5 || ^3.0"
21+
"psr/http-message-implementation": "^1.0"
2322
},
2423
"require-dev": {
2524
"friendsofphp/php-cs-fixer": "^3.0",

src/HttpClient/HttpPluginClientBuilder.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,22 @@ class HttpPluginClientBuilder
3030
private $plugins = [];
3131

3232
/**
33-
* @param ClientInterface|null $httpClient
3433
* @param RequestFactory|RequestFactoryInterface|null $requestFactory
3534
*/
36-
public function __construct(ClientInterface $httpClient = null, $requestFactory = null)
35+
public function __construct(?ClientInterface $httpClient = null, $requestFactory = null)
3736
{
3837
$requestFactory = $requestFactory ?: Psr17FactoryDiscovery::findRequestFactory();
3938
if ($requestFactory instanceof RequestFactory) {
40-
trigger_deprecation(
39+
// Use same format as symfony/deprecation-contracts.
40+
@trigger_error(sprintf(
41+
'Since %s %s: %s is deprecated, use %s instead.',
4142
'private-packagist/api-client',
4243
'1.35.0',
43-
'',
4444
RequestFactory::class,
4545
RequestFactoryInterface::class
46-
);
46+
), \E_USER_DEPRECATED);
4747
} elseif (!$requestFactory instanceof RequestFactoryInterface) {
48+
/** @var mixed $requestFactory value unknown; set to mixed, prevent PHPStan complaining about guard clauses */
4849
throw new \TypeError(sprintf(
4950
'%s::__construct(): Argument #2 ($requestFactory) must be of type %s|%s, %s given',
5051
self::class,

0 commit comments

Comments
 (0)