From 88ed8bea2021bd1c1fcfbea4348c8642407ea464 Mon Sep 17 00:00:00 2001 From: Sebastiaan Stok Date: Mon, 1 Dec 2025 09:57:04 +0100 Subject: [PATCH] Add support for Symfony 8 Support for Symfony 6 and 7 was removed, PHP 8.4 and Symfony 8.0 is now the minimum required version --- .github/workflows/ci.yaml | 24 ++++++----------- .gitignore | 1 - README.md | 8 +++++- UPGRADE.md | 7 +++++ composer.json | 14 +++++----- phpunit.xml.dist | 26 ++++++++++++------- .../RollerworksPasswordStrengthExtension.php | 8 +++--- src/Resources/config/strength_validator.php | 24 +++++++++++++++++ src/Resources/config/strength_validator.xml | 18 ------------- src/RollerworksPasswordStrengthBundle.php | 6 ++++- tests/DependencyInjection/ExtensionTest.php | 9 +++++-- 11 files changed, 86 insertions(+), 59 deletions(-) create mode 100644 src/Resources/config/strength_validator.php delete mode 100644 src/Resources/config/strength_validator.xml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 861ea29..c9edde7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,7 +17,7 @@ jobs: strategy: matrix: php-version: - - '8.2' + - '8.4' steps: - @@ -46,7 +46,7 @@ jobs: - name: 'Install dependencies' - run: 'composer install --no-progress' + run: 'composer update --no-progress --prefer-stable' - name: 'Check the code style' @@ -60,7 +60,7 @@ jobs: strategy: matrix: php-version: - - '8.2' + - '8.4' steps: - @@ -89,7 +89,7 @@ jobs: - name: 'Install dependencies' - run: 'composer install --no-progress' + run: 'composer update --no-progress --prefer-stable' - name: 'Run PhpStan' @@ -104,18 +104,9 @@ jobs: matrix: include: - - php-version: '8.2' + php-version: '8.4' composer-options: '--prefer-stable' - symfony-version: '6.3' - - - php-version: '8.2' - composer-options: '--prefer-stable' - symfony-version: '^6.4' - - - - php-version: '8.2' - composer-options: '--prefer-stable' - symfony-version: '^7.0' + symfony-version: '^8.0' steps: - @@ -154,4 +145,5 @@ jobs: - name: 'Run tests' - run: make phpunit + run: | + vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index e2245b8..0e3ff13 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ composer.lock /vendor/ phpunit.xml -.phpunit.result.cache .phpunit.cache/ .phpunit diff --git a/README.md b/README.md index af9f33e..4c94301 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,13 @@ Otherwise enable the `Rollerworks\Bundle\PasswordStrengthBundle\RollerworksPassw ## Requirements -You need at least PHP PHP 8.2, mbstring is recommended but not required, and at least Symfony 6. +You need at least PHP PHP 8.4 and Symfony 8, mbstring is recommended but not required. + +> [!NOTE] +> +> This package requires PHP 8.4 or higher and Symfony 8 or higher. +> +> If you need support for older Symfony versions, use the [3.x branch](https://github.com/rollerworks/PasswordStrengthBundle/tree/3.x). ## Basic Usage diff --git a/UPGRADE.md b/UPGRADE.md index 0859915..9033437 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,6 +1,13 @@ UPGRADE ======= +From 3.x to 4.0 +--------------- + +* Support for Symfony 6 and 7 was removed, PHP 8.4 and Symfony 8.0 is now the minimum required version. + +* The constructor of password constraints has changed, see (Upgrade instructions of the validator library)[https://github.com/rollerworks/PasswordStrengthValidator/blob/main/UPGRADE.md] + From 2.x to 3.0 --------------- diff --git a/composer.json b/composer.json index 898dbb8..335cf4f 100644 --- a/composer.json +++ b/composer.json @@ -20,15 +20,15 @@ } ], "require": { - "php": ">=8.2", - "rollerworks/password-strength-validator": "^2.0", - "symfony/framework-bundle": "^6.0 || ^7.0" + "php": ">=8.4", + "rollerworks/password-strength-validator": "^3.0", + "symfony/framework-bundle": "^8.0" }, "require-dev": { - "matthiasnoback/symfony-dependency-injection-test": "^5.0 || ^v4.3.1", - "phpunit/phpunit": "^9.5", + "matthiasnoback/symfony-dependency-injection-test": "^6.2", + "phpunit/phpunit": "^12.4", "rollerscapes/standards": "^1.0", - "symfony/phpunit-bridge": "^6.0 || ^7.0" + "symfony/phpunit-bridge": "^8.0" }, "minimum-stability": "dev", "prefer-stable": true, @@ -52,7 +52,7 @@ }, "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "4.0-dev" } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c7d9fc8..d34ab47 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,13 +1,14 @@ + @@ -16,6 +17,8 @@ + + @@ -24,13 +27,16 @@ - + + + - ./src + src/ - ./vendor/ - ./tests/ + src/Resources/ + vendor/ + tests/ - + diff --git a/src/DependencyInjection/RollerworksPasswordStrengthExtension.php b/src/DependencyInjection/RollerworksPasswordStrengthExtension.php index 5e93adb..bc6d3b0 100644 --- a/src/DependencyInjection/RollerworksPasswordStrengthExtension.php +++ b/src/DependencyInjection/RollerworksPasswordStrengthExtension.php @@ -1,5 +1,7 @@ load('strength_validator.xml'); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); + $loader->load('strength_validator.php'); } public function prepend(ContainerBuilder $container): void diff --git a/src/Resources/config/strength_validator.php b/src/Resources/config/strength_validator.php new file mode 100644 index 0000000..39157f9 --- /dev/null +++ b/src/Resources/config/strength_validator.php @@ -0,0 +1,24 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +use Rollerworks\Component\PasswordStrength\Validator\Constraints\PasswordStrengthValidator; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; +use function Symfony\Component\DependencyInjection\Loader\Configurator\service; + +return static function (ContainerConfigurator $container): void { + $di = $container->services(); + + $di->set(PasswordStrengthValidator::class) + ->args([service('translator')->nullOnInvalid()]) + ->tag('validator.constraint_validator'); +}; diff --git a/src/Resources/config/strength_validator.xml b/src/Resources/config/strength_validator.xml deleted file mode 100644 index ab4be5e..0000000 --- a/src/Resources/config/strength_validator.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/RollerworksPasswordStrengthBundle.php b/src/RollerworksPasswordStrengthBundle.php index ed93971..5da22de 100644 --- a/src/RollerworksPasswordStrengthBundle.php +++ b/src/RollerworksPasswordStrengthBundle.php @@ -1,5 +1,7 @@ container->get('validator.validator_factory'); - self::assertInstanceOf(PasswordStrengthValidator::class, $factory->getInstance(new PasswordStrength(['minStrength' => 1]))); + self::assertInstanceOf(PasswordStrengthValidator::class, $factory->getInstance(new PasswordStrength(minStrength: 1))); } protected function getContainerExtensions(): array