From a4d59b3f8bddd1cdb67b90b051437246191e2c30 Mon Sep 17 00:00:00 2001 From: Dominik Wild Date: Sun, 5 Apr 2026 19:02:55 +0200 Subject: [PATCH] compatibility with Symfony 8 --- .../HackzillaPasswordGeneratorExtension.php | 2 +- Tests/Controller/GeneratorControllerTest.php | 14 ++++++-------- Tests/Entity/OptionsTest.php | 4 ++-- Tests/PublicService.php | 4 ++-- Tests/TestKernel.php | 7 ++++++- composer.json | 10 +++++----- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/DependencyInjection/HackzillaPasswordGeneratorExtension.php b/DependencyInjection/HackzillaPasswordGeneratorExtension.php index a6459d9..4fecbb9 100644 --- a/DependencyInjection/HackzillaPasswordGeneratorExtension.php +++ b/DependencyInjection/HackzillaPasswordGeneratorExtension.php @@ -7,7 +7,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\Extension\Extension; /** * This is the class that loads and manages your bundle configuration. diff --git a/Tests/Controller/GeneratorControllerTest.php b/Tests/Controller/GeneratorControllerTest.php index 6a0882a..8a85378 100644 --- a/Tests/Controller/GeneratorControllerTest.php +++ b/Tests/Controller/GeneratorControllerTest.php @@ -65,12 +65,10 @@ public function testGetPasswordGeneratorException(): void $container ->method('get') - ->will( - $this->returnCallback( - function ($service) { - return $service; - } - ) + ->willReturnCallback( + function ($service) { + return $service; + } ); $this->_object->setContainer($container); @@ -79,7 +77,7 @@ function ($service) { $this->invokeMethod($this->_object, 'getPasswordGenerator', ['non-existent']); } - public function modeProvider() + public static function modeProvider() { return [ ['dummy', 'dummy'], @@ -104,7 +102,7 @@ public function testGetMode($mode, $check): void $this->assertSame($check, $returnValue); } - public function nullModeProvider() + public static function nullModeProvider() { return [ ['dummy', 'dummy'], diff --git a/Tests/Entity/OptionsTest.php b/Tests/Entity/OptionsTest.php index 9cd2bde..f871e35 100644 --- a/Tests/Entity/OptionsTest.php +++ b/Tests/Entity/OptionsTest.php @@ -14,7 +14,7 @@ public function setup(): void $this->_object = new \Hackzilla\Bundle\PasswordGeneratorBundle\Entity\Options($passwordGenerator); } - public function quantityProvider() + public static function quantityProvider() { return [ [1, 1], @@ -38,7 +38,7 @@ public function testQuantity($quantity, $check): void $this->assertSame($check, $this->_object->getQuantity()); } - public function optionProvider() + public static function optionProvider() { return [ ['LENGTH', 1], diff --git a/Tests/PublicService.php b/Tests/PublicService.php index b9e6e5f..62ec496 100644 --- a/Tests/PublicService.php +++ b/Tests/PublicService.php @@ -20,7 +20,7 @@ final class PublicService implements CompilerPassInterface 'twig', ]; - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { foreach ($container->getDefinitions() as $id => $definition) { $this->checkForService($id, $definition); @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container) } } - private function checkForService(string $id, $definition) + private function checkForService(string $id, $definition): void { foreach (self::SERVICES as $service) { if (stripos($id, $service) === 0) { diff --git a/Tests/TestKernel.php b/Tests/TestKernel.php index 0fcf88d..32e27e8 100644 --- a/Tests/TestKernel.php +++ b/Tests/TestKernel.php @@ -120,6 +120,9 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load 'form' => null, 'test' => true, ]; + if (version_compare(self::VERSION, '7.3', '>=')) { + $frameworkConfig['property_info'] = ['with_constructor_extractor' => true]; + } if (version_compare(self::VERSION, '5.1', '>=') && version_compare(self::VERSION, '6.0', '<')) { $frameworkConfig['router'] = ['utf8' => true]; @@ -130,12 +133,14 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load // TwigBundle config $twigConfig = [ 'strict_variables' => '%kernel.debug%', - 'exception_controller' => null, ]; // "default_path" configuration is available since version 3.4. if (version_compare(self::VERSION, '3.4', '>=')) { $twigConfig['default_path'] = __DIR__.'/Resources/views'; } + if (version_compare(self::VERSION, '7.3', '<')) { + $twigConfig['exception_controller'] = null; + } $c->loadFromExtension('twig', $twigConfig); } diff --git a/composer.json b/composer.json index 1128a0a..7582560 100644 --- a/composer.json +++ b/composer.json @@ -13,14 +13,14 @@ "require": { "php": "^8.0.2", "hackzilla/password-generator": "^1.3", - "symfony/framework-bundle": "^6.0|^7.0", - "symfony/form": "^6.0|^7.0", - "symfony/twig-bundle": "^6.0|^7.0", - "symfony/serializer": "^6.0|^7.0" + "symfony/framework-bundle": "^6.0|^7.0|^8.0", + "symfony/form": "^6.0|^7.0|^8.0", + "symfony/twig-bundle": "^6.0|^7.0|^8.0", + "symfony/serializer": "^6.0|^7.0|^8.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.0", - "symfony/phpunit-bridge": "^6.0|^7.0", + "symfony/phpunit-bridge": "^6.0|^7.0|^8.0", "phpunit/phpunit": "^9.0" }, "autoload": {