From 9e813ccd966599dea65b94e261a6b7fcfa27670d Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Tue, 21 Nov 2023 17:08:59 +0000 Subject: [PATCH 1/3] Remove more Symfony 4 specific code --- src/DependencyInjection/HttplugExtension.php | 7 +------ tests/Functional/ServiceInstantiationTest.php | 5 +---- tests/Unit/Collector/PluginClientFactoryListenerTest.php | 5 +---- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index 8c611914..c0a590ca 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -33,7 +33,6 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\HttpKernel\Kernel; use Twig\Environment as TwigEnvironment; /** @@ -60,11 +59,7 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('services.xml'); // TODO: Move this back into services.xml when we drop support for Symfony 4, or completely remove the service in the next major version. - if (Kernel::MAJOR_VERSION >= 5) { - $loader->load('services_legacy.xml'); - } else { - $loader->load('services_legacy_sf4.xml'); - } + $loader->load('services_legacy.xml'); $loader->load('plugins.xml'); if (\class_exists(MockClient::class)) { $loader->load('mock-client.xml'); diff --git a/tests/Functional/ServiceInstantiationTest.php b/tests/Functional/ServiceInstantiationTest.php index 37672ee4..1f215ced 100644 --- a/tests/Functional/ServiceInstantiationTest.php +++ b/tests/Functional/ServiceInstantiationTest.php @@ -18,10 +18,8 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\Profiler\Profiler; @@ -132,8 +130,7 @@ protected static function bootKernel(array $options = []): KernelInterface /** @var EventDispatcherInterface $dispatcher */ $dispatcher = static::$kernel->getContainer()->get('event_dispatcher'); - $class = (Kernel::MAJOR_VERSION >= 5) ? RequestEvent::class : GetResponseEvent::class; - $event = new $class(static::$kernel, SymfonyRequest::create('/'), HttpKernelInterface::MASTER_REQUEST); + $event = new RequestEvent(static::$kernel, SymfonyRequest::create('/'), HttpKernelInterface::MAIN_REQUEST); $dispatcher->dispatch($event, KernelEvents::REQUEST); diff --git a/tests/Unit/Collector/PluginClientFactoryListenerTest.php b/tests/Unit/Collector/PluginClientFactoryListenerTest.php index ef2be31a..dae29f80 100644 --- a/tests/Unit/Collector/PluginClientFactoryListenerTest.php +++ b/tests/Unit/Collector/PluginClientFactoryListenerTest.php @@ -11,8 +11,6 @@ use Http\HttplugBundle\Collector\PluginClientFactoryListener; use Nyholm\NSA; use PHPUnit\Framework\TestCase; -use Symfony\Component\EventDispatcher\Event as LegacyEvent; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Contracts\EventDispatcher\Event; @@ -28,8 +26,7 @@ public function testRegisterPluginClientFactory(): void $listener = new PluginClientFactoryListener($factory); - $class = (Kernel::MAJOR_VERSION >= 5) ? Event::class : LegacyEvent::class; - $listener->onEvent(new $class()); + $listener->onEvent(new Event()); $this->assertTrue(is_callable(NSA::getProperty(DefaultPluginClientFactory::class, 'factory'))); } From f350eb2a74256f8e2156130264288e0e72a23bbf Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Thu, 23 Nov 2023 12:17:54 +0000 Subject: [PATCH 2/3] Remove the services_legacy.xml to which previously set up an alias for `Http\Client\HttpClient` --- CHANGELOG.md | 1 + src/DependencyInjection/HttplugExtension.php | 2 -- src/Resources/config/services_legacy.xml | 11 ----------- 3 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 src/Resources/config/services_legacy.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index e69fcb0a..bd227d9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee - Changed the return type of `ClientFactory` to return a `ClientInterface` instead of `ClientInterface|HttpClient` - Changed the type of `httplug.client.default` to `ClientInterface` instead of `HttpClient` - Removed the `DummyClient` interface +- Removed the `Http\Client\HttpClient` alias use the `ClientInterface` typehint in your services for autowiring. # Version 1 diff --git a/src/DependencyInjection/HttplugExtension.php b/src/DependencyInjection/HttplugExtension.php index c0a590ca..3807f95b 100644 --- a/src/DependencyInjection/HttplugExtension.php +++ b/src/DependencyInjection/HttplugExtension.php @@ -58,8 +58,6 @@ public function load(array $configs, ContainerBuilder $container): void $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); - // TODO: Move this back into services.xml when we drop support for Symfony 4, or completely remove the service in the next major version. - $loader->load('services_legacy.xml'); $loader->load('plugins.xml'); if (\class_exists(MockClient::class)) { $loader->load('mock-client.xml'); diff --git a/src/Resources/config/services_legacy.xml b/src/Resources/config/services_legacy.xml deleted file mode 100644 index 99bda890..00000000 --- a/src/Resources/config/services_legacy.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - The "%alias_id%" service is deprecated in favor of using PSR-7 Psr\Http\Client\ClientInterface - - - From a1cad05f0eb418e818f4dc4f148a8c0f62dc6f42 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 24 Nov 2023 14:43:23 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd227d9b..08f8f875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee - Changed the return type of `ClientFactory` to return a `ClientInterface` instead of `ClientInterface|HttpClient` - Changed the type of `httplug.client.default` to `ClientInterface` instead of `HttpClient` - Removed the `DummyClient` interface -- Removed the `Http\Client\HttpClient` alias use the `ClientInterface` typehint in your services for autowiring. +- Removed the `Http\Client\HttpClient` alias use the `Psr\Http\Client\ClientInterface` typehint in your services for autowiring. # Version 1