Skip to content

Commit 8d796dd

Browse files
authored
Remove more Symfony 4 specific code (#443)
1 parent cd98d08 commit 8d796dd

File tree

5 files changed

+3
-26
lines changed

5 files changed

+3
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
1515
- Changed the return type of `ClientFactory` to return a `ClientInterface` instead of `ClientInterface|HttpClient`
1616
- Changed the type of `httplug.client.default` to `ClientInterface` instead of `HttpClient`
1717
- Removed the `DummyClient` interface
18+
- Removed the `Http\Client\HttpClient` alias use the `Psr\Http\Client\ClientInterface` typehint in your services for autowiring.
1819

1920
# Version 1
2021

src/DependencyInjection/HttplugExtension.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
3434
use Symfony\Component\DependencyInjection\Reference;
3535
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
36-
use Symfony\Component\HttpKernel\Kernel;
3736
use Twig\Environment as TwigEnvironment;
3837

3938
/**
@@ -59,12 +58,6 @@ public function load(array $configs, ContainerBuilder $container): void
5958
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
6059

6160
$loader->load('services.xml');
62-
// TODO: Move this back into services.xml when we drop support for Symfony 4, or completely remove the service in the next major version.
63-
if (Kernel::MAJOR_VERSION >= 5) {
64-
$loader->load('services_legacy.xml');
65-
} else {
66-
$loader->load('services_legacy_sf4.xml');
67-
}
6861
$loader->load('plugins.xml');
6962
if (\class_exists(MockClient::class)) {
7063
$loader->load('mock-client.xml');

src/Resources/config/services_legacy.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/Functional/ServiceInstantiationTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1919
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2020
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
21-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
2221
use Symfony\Component\HttpKernel\Event\RequestEvent;
2322
use Symfony\Component\HttpKernel\HttpKernelInterface;
24-
use Symfony\Component\HttpKernel\Kernel;
2523
use Symfony\Component\HttpKernel\KernelEvents;
2624
use Symfony\Component\HttpKernel\KernelInterface;
2725
use Symfony\Component\HttpKernel\Profiler\Profiler;
@@ -132,8 +130,7 @@ protected static function bootKernel(array $options = []): KernelInterface
132130
/** @var EventDispatcherInterface $dispatcher */
133131
$dispatcher = static::$kernel->getContainer()->get('event_dispatcher');
134132

135-
$class = (Kernel::MAJOR_VERSION >= 5) ? RequestEvent::class : GetResponseEvent::class;
136-
$event = new $class(static::$kernel, SymfonyRequest::create('/'), HttpKernelInterface::MASTER_REQUEST);
133+
$event = new RequestEvent(static::$kernel, SymfonyRequest::create('/'), HttpKernelInterface::MAIN_REQUEST);
137134

138135
$dispatcher->dispatch($event, KernelEvents::REQUEST);
139136

tests/Unit/Collector/PluginClientFactoryListenerTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use Http\HttplugBundle\Collector\PluginClientFactoryListener;
1212
use Nyholm\NSA;
1313
use PHPUnit\Framework\TestCase;
14-
use Symfony\Component\EventDispatcher\Event as LegacyEvent;
15-
use Symfony\Component\HttpKernel\Kernel;
1614
use Symfony\Component\Stopwatch\Stopwatch;
1715
use Symfony\Contracts\EventDispatcher\Event;
1816

@@ -28,8 +26,7 @@ public function testRegisterPluginClientFactory(): void
2826

2927
$listener = new PluginClientFactoryListener($factory);
3028

31-
$class = (Kernel::MAJOR_VERSION >= 5) ? Event::class : LegacyEvent::class;
32-
$listener->onEvent(new $class());
29+
$listener->onEvent(new Event());
3330

3431
$this->assertTrue(is_callable(NSA::getProperty(DefaultPluginClientFactory::class, 'factory')));
3532
}

0 commit comments

Comments
 (0)