Skip to content

Commit 1c44ede

Browse files
Skip requiring php-http/message-factory when installing symfony/http-client 6.3+ (#238)
1 parent 5e1ace8 commit 1c44ede

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

.github/workflows/installation.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
method: "Http\\Discovery\\HttpClientDiscovery::find();"
3232
# We should fail if we dont have php-http/message-factory or PSR-17
3333
- expect: cant-find
34-
requirements: "symfony/http-client:^5 php-http/httplug php-http/message-factory guzzlehttp/psr7:^1"
34+
requirements: "symfony/http-client:^5 php-http/httplug guzzlehttp/psr7:^1"
3535
method: "Http\\Discovery\\HttpClientDiscovery::find();"
3636
- expect: cant-find
3737
requirements: "symfony/http-client:^5 php-http/httplug guzzlehttp/psr7:^1 http-interop/http-factory-guzzle"
@@ -58,11 +58,11 @@ jobs:
5858
method: "Http\\Discovery\\Psr18ClientDiscovery::find();"
5959
# Test that we find PSR-18 Symfony 4
6060
- expect: will-find
61-
requirements: "symfony/http-client:^4 php-http/httplug nyholm/psr7:^1.3"
61+
requirements: "symfony/http-client:^4 php-http/httplug php-http/message-factory nyholm/psr7:^1.3"
6262
method: "Http\\Discovery\\Psr18ClientDiscovery::find();"
6363
# Test that we find PSR-18 Symfony 5
6464
- expect: will-find
65-
requirements: "symfony/http-client:^5 php-http/httplug nyholm/psr7:^1.3"
65+
requirements: "symfony/http-client:^5 php-http/httplug php-http/message-factory nyholm/psr7:^1.3"
6666
method: "Http\\Discovery\\Psr18ClientDiscovery::find();"
6767
# Test that we find PSR-17 http-interop
6868
- expect: will-find

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 1.18.0 - 2023-XX-XX
44

55
- [#235](https://github.com/php-http/discovery/pull/235) - Deprecate HttpClientDiscovery, use Psr18ClientDiscovery instead
6+
- [#238](https://github.com/php-http/discovery/pull/238) - Skip requiring php-http/message-factory when installing symfony/http-client 6.3+
67

78
## 1.17.0 - 2023-04-26
89

src/Composer/Plugin.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ class Plugin implements PluginInterface, EventSubscriberInterface
4545
*/
4646
private const PROVIDE_RULES = [
4747
'php-http/async-client-implementation' => [
48+
'symfony/http-client:>=6.3' => ['guzzlehttp/promises', 'psr/http-factory-implementation'],
4849
'symfony/http-client' => ['guzzlehttp/promises', 'php-http/message-factory', 'psr/http-factory-implementation'],
4950
'php-http/guzzle7-adapter' => [],
5051
'php-http/guzzle6-adapter' => [],
5152
'php-http/curl-client' => [],
5253
'php-http/react-adapter' => [],
5354
],
5455
'php-http/client-implementation' => [
56+
'symfony/http-client:>=6.3' => ['psr/http-factory-implementation'],
5557
'symfony/http-client' => ['php-http/message-factory', 'psr/http-factory-implementation'],
5658
'php-http/guzzle7-adapter' => [],
5759
'php-http/guzzle6-adapter' => [],
@@ -332,22 +334,12 @@ public function getMissingRequires(InstalledRepositoryInterface $repo, array $re
332334
}
333335

334336
$dep = key($candidates);
337+
[$dep] = explode(':', $dep, 2);
335338
$missingRequires[$dev][$abstraction] = [$dep];
336339

337340
if ($isProject && !$dev && isset($devPackages[$dep])) {
338341
$missingRequires[2][$abstraction][] = $dep;
339342
}
340-
341-
foreach (current($candidates) as $dep) {
342-
if (isset(self::PROVIDE_RULES[$dep])) {
343-
$abstractions[] = $dep;
344-
} elseif (!isset($allPackages[$dep])) {
345-
$missingRequires[$dev][$abstraction][] = $dep;
346-
} elseif ($isProject && !$dev && isset($devPackages[$dep])) {
347-
$missingRequires[0][$abstraction][] = $dep;
348-
$missingRequires[2][$abstraction][] = $dep;
349-
}
350-
}
351343
}
352344
}
353345

tests/Composer/PluginTest.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ public static function provideMissingRequires()
4242
'psr/http-message-implementation' => [],
4343
'php-http/async-client-implementation' => [
4444
'symfony/http-client',
45-
'guzzlehttp/promises',
46-
'php-http/message-factory',
4745
],
4846
'psr/http-factory-implementation' => [
4947
'nyholm/psr7',
@@ -60,15 +58,10 @@ public static function provideMissingRequires()
6058

6159
$rootRequires = [
6260
'php-http/discovery' => $link,
63-
'php-http/async-client-implementation' => $link,
61+
'psr/http-factory-implementation' => $link,
6462
];
6563

6664
$expected = [[
67-
'php-http/async-client-implementation' => [
68-
'symfony/http-client',
69-
'guzzlehttp/promises',
70-
'php-http/message-factory',
71-
],
7265
'psr/http-factory-implementation' => [
7366
'nyholm/psr7',
7467
],

0 commit comments

Comments
 (0)