Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
method: "Http\\Discovery\\HttpClientDiscovery::find();"
# We should fail if we dont have php-http/message-factory or PSR-17
- expect: cant-find
requirements: "symfony/http-client:^5 php-http/httplug php-http/message-factory guzzlehttp/psr7:^1"
requirements: "symfony/http-client:^5 php-http/httplug guzzlehttp/psr7:^1"
method: "Http\\Discovery\\HttpClientDiscovery::find();"
- expect: cant-find
requirements: "symfony/http-client:^5 php-http/httplug guzzlehttp/psr7:^1 http-interop/http-factory-guzzle"
Expand All @@ -58,11 +58,11 @@ jobs:
method: "Http\\Discovery\\Psr18ClientDiscovery::find();"
# Test that we find PSR-18 Symfony 4
- expect: will-find
requirements: "symfony/http-client:^4 php-http/httplug nyholm/psr7:^1.3"
requirements: "symfony/http-client:^4 php-http/httplug php-http/message-factory nyholm/psr7:^1.3"
method: "Http\\Discovery\\Psr18ClientDiscovery::find();"
# Test that we find PSR-18 Symfony 5
- expect: will-find
requirements: "symfony/http-client:^5 php-http/httplug nyholm/psr7:^1.3"
requirements: "symfony/http-client:^5 php-http/httplug php-http/message-factory nyholm/psr7:^1.3"
method: "Http\\Discovery\\Psr18ClientDiscovery::find();"
# Test that we find PSR-17 http-interop
- expect: will-find
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.18.0 - 2023-XX-XX

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

## 1.17.0 - 2023-04-26

Expand Down
14 changes: 3 additions & 11 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ class Plugin implements PluginInterface, EventSubscriberInterface
*/
private const PROVIDE_RULES = [
'php-http/async-client-implementation' => [
'symfony/http-client:>=6.3' => ['guzzlehttp/promises', 'psr/http-factory-implementation'],
'symfony/http-client' => ['guzzlehttp/promises', 'php-http/message-factory', 'psr/http-factory-implementation'],
'php-http/guzzle7-adapter' => [],
'php-http/guzzle6-adapter' => [],
'php-http/curl-client' => [],
'php-http/react-adapter' => [],
],
'php-http/client-implementation' => [
'symfony/http-client:>=6.3' => ['psr/http-factory-implementation'],
'symfony/http-client' => ['php-http/message-factory', 'psr/http-factory-implementation'],
'php-http/guzzle7-adapter' => [],
'php-http/guzzle6-adapter' => [],
Expand Down Expand Up @@ -332,22 +334,12 @@ public function getMissingRequires(InstalledRepositoryInterface $repo, array $re
}

$dep = key($candidates);
[$dep] = explode(':', $dep, 2);
$missingRequires[$dev][$abstraction] = [$dep];

if ($isProject && !$dev && isset($devPackages[$dep])) {
$missingRequires[2][$abstraction][] = $dep;
}

foreach (current($candidates) as $dep) {
if (isset(self::PROVIDE_RULES[$dep])) {
$abstractions[] = $dep;
} elseif (!isset($allPackages[$dep])) {
$missingRequires[$dev][$abstraction][] = $dep;
} elseif ($isProject && !$dev && isset($devPackages[$dep])) {
$missingRequires[0][$abstraction][] = $dep;
$missingRequires[2][$abstraction][] = $dep;
}
}
}
}

Expand Down
9 changes: 1 addition & 8 deletions tests/Composer/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public static function provideMissingRequires()
'psr/http-message-implementation' => [],
'php-http/async-client-implementation' => [
'symfony/http-client',
'guzzlehttp/promises',
'php-http/message-factory',
],
'psr/http-factory-implementation' => [
'nyholm/psr7',
Expand All @@ -60,15 +58,10 @@ public static function provideMissingRequires()

$rootRequires = [
'php-http/discovery' => $link,
'php-http/async-client-implementation' => $link,
'psr/http-factory-implementation' => $link,
];

$expected = [[
'php-http/async-client-implementation' => [
'symfony/http-client',
'guzzlehttp/promises',
'php-http/message-factory',
],
'psr/http-factory-implementation' => [
'nyholm/psr7',
],
Expand Down