Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove more Symfony 4 specific code #443

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `Psr\Http\Client\ClientInterface` typehint in your services for autowiring.

# Version 1

Expand Down
7 changes: 0 additions & 7 deletions src/DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -59,12 +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.
if (Kernel::MAJOR_VERSION >= 5) {
$loader->load('services_legacy.xml');
} else {
$loader->load('services_legacy_sf4.xml');
}
$loader->load('plugins.xml');
if (\class_exists(MockClient::class)) {
$loader->load('mock-client.xml');
Expand Down
11 changes: 0 additions & 11 deletions src/Resources/config/services_legacy.xml

This file was deleted.

5 changes: 1 addition & 4 deletions tests/Functional/ServiceInstantiationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
5 changes: 1 addition & 4 deletions tests/Unit/Collector/PluginClientFactoryListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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')));
}
Expand Down