diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5941407..7add214 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "8.1", "8.2", "8.3"] + php: ["8.1", "8.2", "8.3"] steps: - uses: actions/checkout@v2 diff --git a/composer.json b/composer.json index 4a6942f..3b1eecb 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ }, "minimum-stability": "stable", "require": { - "php": "^8.0", + "php": "^8.1", "behat/behat": "^3.8.0", "rpkamp/mailhog-client": "^2.0", - "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.0", + "symfony/dependency-injection": "^6.4 || ^7.0", "psr-discovery/http-client-implementations": "^1.0", "psr-discovery/http-factory-implementations": "^1.0", - "symfony/http-client": "^5.4 || ^6.4" + "symfony/http-client": "^6.4 || ^7.0" }, "require-dev": { "guzzlehttp/psr7": "^1.6", diff --git a/src/ServiceContainer/MailhogExtension.php b/src/ServiceContainer/MailhogExtension.php index 1ca40f8..cff9a8c 100644 --- a/src/ServiceContainer/MailhogExtension.php +++ b/src/ServiceContainer/MailhogExtension.php @@ -21,8 +21,6 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -use function method_exists; - /** * This class configures a lot of services, so needs access * to a lot of classes. Therefore high coupling is allowed here. @@ -69,7 +67,6 @@ private function registerHttpClient(ContainerBuilder $container): void { $httpClient = new Definition(ClientInterface::class); $httpClient->setFactory([Discover::class, 'httpClient']); - $this->markServicePrivate($httpClient); $container->setDefinition('mailhog.http_client', $httpClient); } @@ -78,7 +75,6 @@ private function registerHttpMessageFactory(ContainerBuilder $container): void { $httpRequestFactory = new Definition(RequestFactoryInterface::class); $httpRequestFactory->setFactory([Discover::class, 'httpRequestFactory']); - $this->markServicePrivate($httpRequestFactory); $container->setDefinition('mailhog.http_request_factory', $httpRequestFactory); } @@ -87,7 +83,6 @@ private function registerHttpStreamFactory(ContainerBuilder $container): void { $httpStreamFactory = new Definition(StreamFactoryInterface::class); $httpStreamFactory->setFactory([Discover::class, 'httpStreamFactory']); - $this->markServicePrivate($httpStreamFactory); $container->setDefinition('mailhog.http_stream_factory', $httpStreamFactory); } @@ -100,7 +95,7 @@ private function registerMailhogClient(ContainerBuilder $container): void new Reference('mailhog.http_stream_factory'), '%mailhog.base_url%', ]); - $this->markServicePublic($mailhogClient); + $mailhogClient->setPublic(true); $container->setDefinition('mailhog.client', $mailhogClient); } @@ -112,14 +107,12 @@ private function registerContextInitializer(ContainerBuilder $container): void ]); $contextInitializer->addTag(ContextExtension::INITIALIZER_TAG, ['priority' => 0]); - $this->markServicePrivate($contextInitializer); $container->setDefinition('mailhog.context_initializer', $contextInitializer); } private function registerOpenedEmailStorage(ContainerBuilder $container): void { $openedEmailStorage = new Definition(OpenedEmailStorage::class); - $this->markServicePrivate($openedEmailStorage); $container->setDefinition('mailhog.opened_email_storage', $openedEmailStorage); } @@ -130,7 +123,6 @@ private function registerOpenedEmailStorageContextInitializer(ContainerBuilder $ new Reference('mailhog.opened_email_storage'), ]); $openMailInitializer->addTag(ContextExtension::INITIALIZER_TAG, ['priority' => 0]); - $this->markServicePrivate($openMailInitializer); $container->setDefinition('mailhog.opened_email_storage.context_initializer', $openMailInitializer); } @@ -142,33 +134,10 @@ private function registerPurgeListener(ContainerBuilder $container): void '%mailhog.purge_tag%', ]); $listener->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, ['priority' => 0]); - $this->markServicePrivate($listener); $container->setDefinition('mailhog.purge_listener', $listener); } - private function markServicePrivate(Definition $definition): void - { - if (!method_exists($definition, 'setPrivate')) { - // symfony/dependency-injection >= 3.4 where - // all services are private by default - return; - } - - $definition->setPrivate(true); - } - - public function markServicePublic(Definition $definition): void - { - if (!method_exists($definition, 'setPublic')) { - // symfony/dependency-injection < 3.4 where - // all services are public by default - return; - } - - $definition->setPublic(true); - } - public function process(ContainerBuilder $container): void { } diff --git a/tests/ServiceContainer/MailhogExtensionTest.php b/tests/ServiceContainer/MailhogExtensionTest.php index 8240736..8b074fd 100644 --- a/tests/ServiceContainer/MailhogExtensionTest.php +++ b/tests/ServiceContainer/MailhogExtensionTest.php @@ -5,8 +5,6 @@ use Behat\Behat\Context\ServiceContainer\ContextExtension; use Behat\Testwork\EventDispatcher\ServiceContainer\EventDispatcherExtension; -use Http\Client\HttpClient; -use Http\Message\MessageFactory; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\StreamFactoryInterface; @@ -19,7 +17,6 @@ use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpClient\Psr18Client; -use Symfony\Contracts\HttpClient\HttpClientInterface; final class MailhogExtensionTest extends TestCase {