diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 96e31df..4c70266 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,11 +10,12 @@ on: jobs: php: - name: "PHP ${{ matrix.php-version }} Symfony ${{ matrix.symfony-version }}" + name: "PHP ${{ matrix.php-version }} Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}}" runs-on: ubuntu-latest env: KERNEL_CLASS: PHPCR\PhpcrMigrationsBundle\Tests\Resources\App\AppKernel + SYMFONY_REQUIRE: ${{ matrix.symfony-version }} strategy: fail-fast: false @@ -24,10 +25,11 @@ jobs: symfony-version: '^5.4' - php-version: '8.1' - symfony-version: '6.0.*' + symfony-version: '^6.0' + dependencies: 'lowest' - php-version: '8.1' - symfony-version: '^6.0' + symfony-version: '^6.4' - php-version: '8.2' @@ -42,16 +44,15 @@ jobs: with: php-version: ${{ matrix.php-version }} extensions: ctype, iconv, mysql + tools: composer:v2, flex ini-values: memory_limit=-1 coverage: none - - name: Add additional packages - run: | - composer require symfony/symfony:${{ matrix.symfony-version }} --no-update - if: ${{ matrix.symfony-version }} - - - name: Install composer dependencies + - name: Install dependencies with Composer uses: ramsey/composer-install@v3 + with: + dependency-versions: ${{ matrix.dependencies }} + composer-options: --prefer-dist - name: Prepare phpcr odm doctrine dbal run: vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 9f3eada..eaf043c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -2,7 +2,9 @@ $finder = PhpCsFixer\Finder::create() ->in('src/') - ->in('tests/'); + ->in('tests/') + ->exclude('tests/Resources/App/var/') +; $config = new PhpCsFixer\Config(); return $config->setFinder($finder) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ae38f2..b39159e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,21 @@ CHANGELOG ========= +1.x +=== + +1.6.0 +----- + +* Deprecate using `Symfony\Component\DependencyInjection\ContainerAwareInterface` in favor of + `PHPCR\PhpcrMigrationsBundle\ContainerAwareInterface` as Symfony 7 dropped its + ContainerAwareInterface. + On Symfony 6, the legacy ContainerAwareInterface continues to be supported. + 1.5.0 ----- -* Allow installation with Symfony 7 +* Allow installation with Symfony 7 (! broken if you use `Symfony\Component\DependencyInjection\ContainerAwareInterface`) * Drop support for PHP < 8.1 and modernize code 1.4.0 diff --git a/composer.json b/composer.json index 312caa2..49218cd 100644 --- a/composer.json +++ b/composer.json @@ -16,19 +16,27 @@ "php": "^8.1", "phpcr/phpcr-migrations": "^1.1", "phpcr/phpcr-implementation": "^2.1", - "doctrine/phpcr-bundle": "^1.3 || ^2.0", + "doctrine/phpcr-bundle": "^2.2 || ^3.0", "symfony/config": "^5.4 || ^6.0 || ^7.0", "symfony/console": "^5.4 || ^6.0 || ^7.0", "symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0", "symfony/http-kernel": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { - "doctrine/doctrine-bundle": "^1.8 || ^2.0", + "doctrine/doctrine-bundle": "^1.8 || ^2.5", "doctrine/phpcr-odm": "^1.4 || ^2.0", + "doctrine/annotations": "^1.14 || ^2.0", + "jackalope/jackalope-doctrine-dbal": "^1.4 || ^2.0", "symfony/monolog-bundle": "^3.0", - "symfony/phpunit-bridge": "^7.0", - "symfony/symfony": "^5.4 || ^6.0 || ^7.0", - "symfony-cmf/testing": "^2.1 || ^3.0 || ^4.0" + "symfony/phpunit-bridge": "^7.0.6", + "symfony-cmf/testing": "^4.5.0", + "symfony/security-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0", + "symfony/translation": "^5.4 || ^6.0 || ^7.0", + "symfony/form": "^5.4 || ^6.0 || ^7.0", + "symfony/validator": "^5.4 || ^6.0 || ^7.0", + "symfony/property-access": "^5.4 || ^6.0 || ^7.0" }, "autoload": { "psr-4": { diff --git a/src/Command/MigrateCommand.php b/src/Command/MigrateCommand.php index a955fb5..c9d7628 100644 --- a/src/Command/MigrateCommand.php +++ b/src/Command/MigrateCommand.php @@ -12,11 +12,12 @@ namespace PHPCR\PhpcrMigrationsBundle\Command; use PHPCR\Migrations\MigratorFactory; +use PHPCR\PhpcrMigrationsBundle\ContainerAwareInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareInterface as SymfonyContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; class MigrateCommand extends Command @@ -77,6 +78,9 @@ public function execute(InputInterface $input, OutputInterface $output): int foreach ($migrator->getVersions() as $version) { if ($version instanceof ContainerAwareInterface) { $version->setContainer($this->container); + } elseif ($version instanceof SymfonyContainerAwareInterface) { + $version->setContainer($this->container); + @trigger_error('Relying on '.SymfonyContainerAwareInterface::class.' is deprecated and will break when upgrading to Symfony 7. Use '.ContainerAwareInterface::class.' instead.', \E_USER_DEPRECATED); } } diff --git a/src/ContainerAwareInterface.php b/src/ContainerAwareInterface.php new file mode 100644 index 0000000..048b637 --- /dev/null +++ b/src/ContainerAwareInterface.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PHPCR\PhpcrMigrationsBundle; + +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * Interface for migrations to get the Symfony container injected. + */ +interface ContainerAwareInterface +{ + public function setContainer(?ContainerInterface $container = null): void; +} diff --git a/tests/Functional/BaseTestCase.php b/tests/Functional/BaseTestCase.php index caa7855..462ebda 100644 --- a/tests/Functional/BaseTestCase.php +++ b/tests/Functional/BaseTestCase.php @@ -11,11 +11,14 @@ namespace PHPCR\PhpcrMigrationsBundle\Tests\Functional; +use PHPCR\SessionInterface; use Symfony\Cmf\Component\Testing\Functional\BaseTestCase as CmfBaseTestCase; use Symfony\Component\Console\Tester\CommandTester; abstract class BaseTestCase extends CmfBaseTestCase { + protected SessionInterface $session; + public function setUp(): void { $this->db('PHPCR')->purgeRepository(); diff --git a/tests/Functional/MigrateCommandTest.php b/tests/Functional/MigrateCommandTest.php index 8ac0361..76027c4 100644 --- a/tests/Functional/MigrateCommandTest.php +++ b/tests/Functional/MigrateCommandTest.php @@ -14,7 +14,7 @@ class MigrateCommandTest extends BaseTestCase { /** - * It should migrate all the unexecuted migrators. + * It should migrate all the non-executed migrators. */ public function testMigrateToLatest(): void { diff --git a/tests/Resources/App/AppKernel.php b/tests/Resources/App/AppKernel.php index 4c4190f..ee7e380 100644 --- a/tests/Resources/App/AppKernel.php +++ b/tests/Resources/App/AppKernel.php @@ -20,7 +20,7 @@ class AppKernel extends TestKernel { - public function configure() + public function configure(): void { $this->requireBundleSets([ 'default', @@ -34,14 +34,14 @@ public function configure() ]); } - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->import(CMF_TEST_CONFIG_DIR.'/default.php'); $loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php'); - $loader->load(__DIR__.'/config/config.yml'); + $loader->load(__DIR__.'/config/config.php'); } - protected function prepareContainer(ContainerBuilder $container) + protected function prepareContainer(ContainerBuilder $container): void { parent::prepareContainer($container); $container->setParameter('cmf_testing.bundle_fqn', 'Phpcr\PhpcrMigrationsBundle\PhpcrMigrationsBundle'); diff --git a/tests/Resources/App/config/config.php b/tests/Resources/App/config/config.php new file mode 100644 index 0000000..2960549 --- /dev/null +++ b/tests/Resources/App/config/config.php @@ -0,0 +1,15 @@ + true, +]; + +if (class_exists(Symfony\Component\Validator\Mapping\Loader\AnnotationLoader::class)) { + // Symfony < 7 + $frameworkConfig['annotations'] = true; +} + +$container->loadFromExtension('framework', $frameworkConfig); +$container->loadFromExtension('phpcr_migrations', [ + 'version_node_name' => 'jcr:migrations', +]); diff --git a/tests/Resources/App/config/config.yml b/tests/Resources/App/config/config.yml deleted file mode 100644 index e2a2126..0000000 --- a/tests/Resources/App/config/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -phpcr_migrations: - version_node_name: "jcr:migrations" - -framework: - annotations: true diff --git a/tests/Resources/Bundle/TwoTestBundle/Resources/phpcr-migrations/Version201401011300.php b/tests/Resources/Bundle/TwoTestBundle/Resources/phpcr-migrations/Version201401011300.php index 8be6e9c..49b28c4 100644 --- a/tests/Resources/Bundle/TwoTestBundle/Resources/phpcr-migrations/Version201401011300.php +++ b/tests/Resources/Bundle/TwoTestBundle/Resources/phpcr-migrations/Version201401011300.php @@ -10,15 +10,15 @@ */ use PHPCR\Migrations\VersionInterface; +use PHPCR\PhpcrMigrationsBundle\ContainerAwareInterface; use PHPCR\SessionInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; class Version201401011300 implements VersionInterface, ContainerAwareInterface { private $container; - public function setContainer(?ContainerInterface $container = null) + public function setContainer(?ContainerInterface $container = null): void { $this->container = $container; }