diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0060747..0149c6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: name: Analyze runs-on: ubuntu-latest container: - image: php:8.3-alpine + image: php:8.5-alpine options: >- --tmpfs /tmp:exec --tmpfs /var/tmp:exec @@ -27,13 +27,13 @@ jobs: - uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-8.3-highest-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-8.5-highest-${{ hashFiles('**/composer.json') }} restore-keys: | - ${{ runner.os }}-composer-8.3-highest + ${{ runner.os }}-composer-8.5-highest - name: Validate Composer run: composer validate - name: Install highest dependencies with Composer - run: composer update --no-progress --no-suggest --ansi + run: composer update --no-progress --ansi - name: Disable PHP memory limit run: echo 'memory_limit=-1' >> /usr/local/etc/php/php.ini - name: Run CS-Fixer @@ -50,19 +50,10 @@ jobs: strategy: matrix: php: - - '8.1' - - '8.2' - - '8.3' + - '8.5' dependencies: - 'lowest' - 'highest' - include: - - php: '8.1' - phpunit-version: 10 - - php: '8.2' - phpunit-version: 10 - - php: '8.3' - phpunit-version: 10 fail-fast: false steps: - name: Checkout @@ -81,13 +72,11 @@ jobs: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.dependencies }} - name: Install lowest dependencies with Composer if: matrix.dependencies == 'lowest' - run: composer update --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi + run: composer update --no-progress --prefer-stable --prefer-lowest --ansi - name: Install highest dependencies with Composer if: matrix.dependencies == 'highest' - run: composer update --no-progress --no-suggest --ansi + run: composer update --no-progress --ansi - name: Run tests with PHPUnit - env: - SYMFONY_MAX_PHPUNIT_VERSION: ${{ matrix.phpunit-version }} run: vendor/bin/simple-phpunit --colors=always # coverage: diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 7b8eb43..f71c931 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -18,7 +18,7 @@ ->setRiskyAllowed(true) ->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers()) ->setRules([ - '@PHP82Migration' => true, + '@PHP85Migration' => true, '@PhpCsFixer' => true, '@PhpCsFixer:risky' => true, diff --git a/composer.json b/composer.json index 8c55b73..30afb0e 100644 --- a/composer.json +++ b/composer.json @@ -16,24 +16,24 @@ } ], "require": { - "php": "^8.1", - "doctrine/persistence": "^2.0|^3.0|^4.0", - "symfony/config": "^5.4.30|^6.3|^7.0", - "symfony/dependency-injection": "^5.4.30|^6.3|^7.0", - "symfony/doctrine-bridge": "^5.4.30|^6.3|^7.0", - "symfony/form": "^5.4.30|^6.3|^7.0", - "symfony/http-kernel": "^5.4.30|^6.3|^7.0" + "php": "^8.5", + "doctrine/persistence": "^3.0|^4.0", + "symfony/config": "^8.0", + "symfony/dependency-injection": "^8.0", + "symfony/doctrine-bridge": "^8.0", + "symfony/form": "^8.0", + "symfony/http-kernel": "^8.0" }, "require-dev": { - "doctrine/orm": "^2.15|^3.0", - "friendsofphp/php-cs-fixer": "^3.45", + "doctrine/orm": "^3.0", + "friendsofphp/php-cs-fixer": "^3.66", "kubawerlos/php-cs-fixer-custom-fixers": "^3.18", - "phpstan/phpstan": "^1.10", - "rector/rector": "^0.18", - "symfony/cache": "^5.4.30|^6.3|^7.0", - "symfony/phpunit-bridge": "^5.4.30|^6.3|^7.0", - "symfony/validator": "^5.4.30|^6.3|^7.0", - "vimeo/psalm": "^5.18" + "phpstan/phpstan": "^2.1", + "rector/rector": "^2.0", + "symfony/cache": "^8.0", + "symfony/phpunit-bridge": "^8.0", + "symfony/validator": "^8.0", + "vimeo/psalm": "^6.0" }, "suggest": { "a2lix/translation-form-bundle": "For translation form" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9afc01d..b51cab0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,29 +1,29 @@ - + - + src/ src/Resources - + - + - - - + + + diff --git a/rector.php b/rector.php index e6244a4..4d41d21 100644 --- a/rector.php +++ b/rector.php @@ -3,35 +3,16 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Core\ValueObject\PhpVersion; -use Rector\Doctrine\Set\DoctrineSetList; -use Rector\PHPUnit\Set\PHPUnitLevelSetList; -use Rector\PHPUnit\Set\PHPUnitSetList; -use Rector\Set\ValueObject\LevelSetList; -use Rector\Symfony\Set\SymfonyLevelSetList; -use Rector\Symfony\Set\SymfonySetList; -use Rector\Symfony\Set\TwigSetList; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->parallel(); - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__.'/src', __DIR__.'/tests', - ]); - $rectorConfig->importNames(); - $rectorConfig->importShortClasses(false); - - $rectorConfig->phpVersion(PhpVersion::PHP_82); - $rectorConfig->sets([ - LevelSetList::UP_TO_PHP_82, - - DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES, - // DoctrineSetList::DOCTRINE_CODE_QUALITY, - DoctrineSetList::DOCTRINE_ORM_214, - DoctrineSetList::DOCTRINE_DBAL_30, - - PHPUnitLevelSetList::UP_TO_PHPUNIT_91, - // PHPUnitSetList::PHPUNIT_CODE_QUALITY, - // PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER, - ]); -}; + ]) + ->withImportNames(importShortClasses: false) + ->withPhpSets() + ->withComposerBased( + symfony: true, + doctrine: true, + phpunit: true, + ); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index ef33d2d..faf4ac2 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -21,7 +21,7 @@ class Configuration implements ConfigurationInterface public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('a2lix_auto_form'); - $rootNode = method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('a2lix_auto_form'); + $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() diff --git a/src/Form/Manipulator/DoctrineORMManipulator.php b/src/Form/Manipulator/DoctrineORMManipulator.php index aa37e90..9c2636c 100644 --- a/src/Form/Manipulator/DoctrineORMManipulator.php +++ b/src/Form/Manipulator/DoctrineORMManipulator.php @@ -112,6 +112,6 @@ private function checkFieldIsValid($formFieldName, $formFieldConfig, $validObjec return; } - throw new \RuntimeException(sprintf("Field '%s' doesn't exist in %s", $formFieldName, $class)); + throw new \RuntimeException(\sprintf("Field '%s' doesn't exist in %s", $formFieldName, $class)); } } diff --git a/src/ObjectInfo/DoctrineORMInfo.php b/src/ObjectInfo/DoctrineORMInfo.php index cb24946..9428ba4 100644 --- a/src/ObjectInfo/DoctrineORMInfo.php +++ b/src/ObjectInfo/DoctrineORMInfo.php @@ -46,7 +46,7 @@ public function getAssociationTargetClass(string $class, string $fieldName): str $metadata = $this->classMetadataFactory->getMetadataFor($class); if (!$metadata->hasAssociation($fieldName)) { - throw new \RuntimeException(sprintf('Unable to find the association target class of "%s" in %s.', $fieldName, $class)); + throw new \RuntimeException(\sprintf('Unable to find the association target class of "%s" in %s.', $fieldName, $class)); } return $metadata->getAssociationTargetClass($fieldName); diff --git a/tests/Form/Type/AutoFormTypeAdvancedTest.php b/tests/Form/Type/AutoFormTypeAdvancedTest.php index 2685e59..02c06a5 100755 --- a/tests/Form/Type/AutoFormTypeAdvancedTest.php +++ b/tests/Form/Type/AutoFormTypeAdvancedTest.php @@ -139,6 +139,7 @@ public function testCreationFormWithOverriddenFieldsMappedFalse(): Product return $product; } + #[\Override] protected function getExtensions(): array { $autoFormType = $this->getConfiguredAutoFormType(); diff --git a/tests/Form/Type/AutoFormTypeSimpleTest.php b/tests/Form/Type/AutoFormTypeSimpleTest.php index 2d9767b..9b71b5e 100755 --- a/tests/Form/Type/AutoFormTypeSimpleTest.php +++ b/tests/Form/Type/AutoFormTypeSimpleTest.php @@ -17,6 +17,7 @@ use A2lix\AutoFormBundle\Tests\Fixtures\Entity\Media; use A2lix\AutoFormBundle\Tests\Fixtures\Entity\Product; use A2lix\AutoFormBundle\Tests\Form\TypeTestCase; +use PHPUnit\Framework\Attributes\Depends; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\PreloadedExtension; @@ -82,9 +83,7 @@ public function testCreationForm(): Product return $product; } - /** - * @depends testCreationForm - */ + #[Depends('testCreationForm')] public function testEditionForm(Product $product): void { $product->getMedias()[0]->setUrl('http://example.org/media1-edit'); @@ -121,6 +120,7 @@ public function testEditionForm(Product $product): void } } + #[\Override] protected function getExtensions(): array { $autoFormType = $this->getConfiguredAutoFormType(); diff --git a/tests/Form/TypeTestCase.php b/tests/Form/TypeTestCase.php index f83e385..6cb1802 100755 --- a/tests/Form/TypeTestCase.php +++ b/tests/Form/TypeTestCase.php @@ -61,7 +61,8 @@ protected function getDoctrineORMManipulator(): DoctrineORMManipulator return $this->doctrineORMManipulator; } - $config = ORMSetup::createAttributeMetadataConfiguration([__DIR__.'/../Fixtures/Entity'], true); + $config = ORMSetup::createAttributeMetadataConfig([__DIR__.'/../Fixtures/Entity'], true); + $config->enableNativeLazyObjects(true); $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true], $config); $entityManager = new EntityManager($connection, $config); $doctrineORMInfo = new DoctrineORMInfo($entityManager->getMetadataFactory());