diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index b3fd1069..fbe756da 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -12,22 +12,16 @@ jobs: test: name: "PHP ${{ matrix.php-version }}, Symfony ${{ matrix.symfony-version }}" runs-on: "ubuntu-20.04" + env: + SYMFONY_REQUIRE: ${{matrix.symfony-require}} strategy: fail-fast: false matrix: include: - - php-version: "7.4" - phpunit-version: "8.5" - dependencies: "lowest" - - - php-version: "7.4" - phpunit-version: "8.5" - phpunit-flags: "-v --coverage-text" - symfony-version: "^5.4" - - - php-version: "8.0" + - php-version: "8.1" phpunit-version: "9.5" + phpunit-flags: "-v --coverage-text" symfony-version: "6.0.*" - php-version: "8.1" @@ -36,9 +30,13 @@ jobs: - php-version: "8.2" phpunit-version: "9.5" + - php-version: "8.3" + phpunit-version: "9.5" + symfony-version: "7.*" + steps: - name: "Checkout project" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" - name: "Install and configure PHP" uses: "shivammathur/setup-php@v2" @@ -47,11 +45,13 @@ jobs: extensions: "pdo, pdo_sqlite" tools: "composer:v2" - - name: "Require Specific Symfony Version" + - name: "Require specific symfony version" if: "${{ matrix.symfony-version }}" - run: "composer require --no-update symfony/symfony:${{ matrix.symfony-version }}" + run: | + composer require --no-update symfony/flex + composer config --no-plugins allow-plugins.symfony/flex true - - name: "Require Additional dependencies" + - name: "Require additional dependencies" if: "${{ matrix.composer-require }}" run: "composer require --no-update ${{ matrix.composer-require }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 5278955d..7155e991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,12 @@ Changelog * Upgrade to phpcr-odm 2.0 * Support jackalope 2.0 +* Drop support for PHP 7 * Replace doctrine cache with PSR-6 cache with the symfony/cache implementation. The configuration of metadata_cache_driver changed. By default, it creates an `array` cache. To configure a service, specify `type: service` and specify your service in the `id` property. To use a cache pool, specify the service id of that pool. +* Removed support for namespace alias, use the FQN names. * Introduced the ManagerRegistryInterface for the ManagerRegistry and adjusted the service alias for autowiring to the interface. * The following container parameters are no longer taken into account (memcache and apc seem to have never been used anyways). If you have customised the array cache class, please check if this is still needed - and note that starting from this version, @@ -26,6 +28,7 @@ Changelog doctrine_phpcr.odm.cache.memcached_port doctrine_phpcr.odm.cache.memcached_instance.class doctrine_phpcr.odm.cache.xcache.class + * If no username is defined for a session, and if you use Jackalope >= 2.0, the credentials service for this session is no longer created and `null` is passed as credentials. diff --git a/composer.json b/composer.json index a5e96197..047abe39 100644 --- a/composer.json +++ b/composer.json @@ -21,36 +21,40 @@ } ], "require": { - "php": "^7.4 || ^8.0", - "phpcr/phpcr-utils": "^1.3", - "symfony/doctrine-bridge": "^5.4 || ^6.0", - "symfony/framework-bundle": "^5.4 || ^6.0", - "symfony/cache": "^5.4 || ^6.0" + "php": "^8.0", + "ext-dom": "*", + "phpcr/phpcr-utils": "^1.3 || ^2.0", + "symfony/cache": "^5.4 || ^6.0 || ^7.0", + "symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0", + "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0" }, "conflict": { "doctrine/annotations": "< 1.7.0", "doctrine/doctrine-bundle": "< 2.0.3", "jackalope/jackalope": "< 1.3.1", - "phpcr/phpcr-shell": "< 1.0.0-beta1" + "phpcr/phpcr-shell": "< 1.0.0-beta1", + "symfony/dependency-injection": "< 3", + "symfony/console": "< 4" }, "require-dev": { "doctrine/doctrine-bundle": "^2.0.3", - "doctrine/phpcr-odm": "^2.0", - "jackalope/jackalope-doctrine-dbal": "^1.3 || ^2.0", - "matthiasnoback/symfony-dependency-injection-test": "^4.1", - "symfony/asset": "^5.4 || ^6.0", - "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/css-selector": "^5.4 || ^6.0", - "symfony/error-handler": "^4.4 || ^5.0 || ^6.0", - "symfony/form": "^5.4 || ^6.0", - "symfony/monolog-bridge": "^5.4 || ^6.0", + "doctrine/phpcr-odm": "2.x-dev", + "doctrine/orm": "^2.0 || ^3.0", + "jackalope/jackalope-doctrine-dbal": "^2.0", + "matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0", + "symfony/asset": "^5.4 || ^6.0 || ^7.0", + "symfony/browser-kit": "^5.4 || ^6.0 || ^7.0", + "symfony/css-selector": "^5.4 || ^6.0 || ^7.0", + "symfony/error-handler": "^5.4 || ^6.0 || ^7.0", + "symfony/form": "^5.4 || ^6.0 || ^7.0", + "symfony/monolog-bridge": "^5.4 || ^6.0 || ^7.0", "symfony/monolog-bundle": "^3.4", "symfony/phpunit-bridge": "^v6.4.2 || ^v7.0.2", - "symfony/templating": "^5.4 || ^6.0", - "symfony/translation": "^5.4 || ^6.0", - "symfony/twig-bundle": "^5.4 || ^6.0", - "symfony/validator": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0" + "symfony/templating": "^5.4 || ^6.0 || ^7.0", + "symfony/translation": "^5.4 || ^6.0 || ^7.0", + "symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0", + "symfony/validator": "^5.4 || ^6.0 || ^7.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0 || ^7.0" }, "suggest": { "burgov/key-value-form-bundle": "to edit assoc multivalue properties. require version 1.0.*", @@ -78,5 +82,6 @@ "Doctrine\\Bundle\\PHPCRBundle\\Tests\\": "tests/" } }, + "prefer-stable": true, "minimum-stability": "beta" } diff --git a/src/CacheWarmer/UniqueNodeTypeCacheWarmer.php b/src/CacheWarmer/UniqueNodeTypeCacheWarmer.php index 471430e7..965911a8 100644 --- a/src/CacheWarmer/UniqueNodeTypeCacheWarmer.php +++ b/src/CacheWarmer/UniqueNodeTypeCacheWarmer.php @@ -29,12 +29,14 @@ public function isOptional(): bool return true; } - public function warmUp($cacheDir): void + public function warmUp(string $cacheDir, ?string $buildDir = null): array { $helper = new UniqueNodeTypeHelper(); foreach ($this->registry->getManagers() as $documentManager) { $helper->checkNodeTypeMappings($documentManager); } + + return []; } } diff --git a/src/Command/LoadFixtureCommand.php b/src/Command/LoadFixtureCommand.php index 897eeeb9..508389a6 100644 --- a/src/Command/LoadFixtureCommand.php +++ b/src/Command/LoadFixtureCommand.php @@ -3,18 +3,17 @@ namespace Doctrine\Bundle\PHPCRBundle\Command; use Doctrine\Bundle\PHPCRBundle\DataFixtures\PHPCRExecutor; +use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager; +use Doctrine\Common\DataFixtures\Loader; use Doctrine\Common\DataFixtures\Purger\PHPCRPurger; +use Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper; use InvalidArgumentException; -use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Helper\DialogHelper; -use Symfony\Component\Console\Helper\QuestionHelper; +use PHPCR\Util\Console\Command\BaseCommand; +use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ConfirmationQuestion; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; -use Symfony\Component\HttpKernel\KernelInterface; /** * Command to load PHPCR-ODM fixtures. @@ -24,14 +23,20 @@ * @author Jonathan H. Wage * @author Daniel Leech */ -class LoadFixtureCommand extends Command +class LoadFixtureCommand extends BaseCommand { - use ContainerAwareTrait; + private const NAME = 'doctrine:phpcr:fixtures:load'; + + public function __construct( + private InitializerManager $initializerManager + ) { + parent::__construct(self::NAME); + } protected function configure(): void { $this - ->setName('doctrine:phpcr:fixtures:load') + ->setName(self::NAME) ->setDescription('Load data fixtures to your PHPCR database.') ->addOption('fixtures', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'The directory or file to load data fixtures from.') ->addOption('append', null, InputOption::VALUE_NONE, 'Append the data fixtures to the existing data - will not purge the workspace.') @@ -65,28 +70,24 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { $dmName = $input->getOption('dm'); // defaults to null + $application = $this->getApplication(); + if (!$application instanceof Application) { + throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '. + ($application ? \get_class($application) : null)); + } DoctrineCommandHelper::setApplicationDocumentManager( - $this->getApplication(), + $application, $dmName ); - $dm = $this->getHelperSet()->get('phpcr')->getDocumentManager(); + $dm = $this->getPhpcrHelper()->getDocumentManager(); $noInitialize = $input->getOption('no-initialize'); if ($input->isInteractive() && !$input->getOption('append')) { $question = 'Careful, database will be purged. Do you want to continue Y/N ?'; - $default = false; - if ($this->getHelperSet()->has('question')) { - /** @var $questionHelper QuestionHelper */ - $questionHelper = $this->getHelperSet()->get('question'); - $question = new ConfirmationQuestion($question, $default); - $result = $questionHelper->ask($input, $output, $question); - } else { - /** @var $dialog DialogHelper */ - $dialog = $this->getHelperSet()->get('dialog'); - $result = $dialog->askConfirmation($output, $question, $default); - } - + $questionHelper = $this->getQuestionHelper(); + $question = new ConfirmationQuestion($question, false); + $result = $questionHelper->ask($input, $output, $question); if (!$result) { return 0; } @@ -96,8 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($dirOrFile) { $paths = \is_array($dirOrFile) ? $dirOrFile : [$dirOrFile]; } else { - /** @var $kernel KernelInterface */ - $kernel = $this->getApplication()->getKernel(); + $kernel = $application->getKernel(); $projectDir = method_exists($kernel, 'getRootDir') ? $kernel->getRootDir() : $kernel->getProjectDir().'/src'; $paths = [$projectDir.'/DataFixtures/PHPCR']; foreach ($kernel->getBundles() as $bundle) { @@ -105,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - $loader = new ContainerAwareLoader($this->container); + $loader = new Loader(); foreach ($paths as $path) { if (is_dir($path)) { $loader->loadFromDirectory($path); @@ -123,13 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $purger = new PHPCRPurger($dm); - if ($noInitialize) { - $initializerManager = null; - } else { - $initializerManager = $this->container->get('doctrine_phpcr.initializer_manager'); - } - - $executor = new PHPCRExecutor($dm, $purger, $initializerManager); + $executor = new PHPCRExecutor($dm, $purger, $noInitialize ? null : $this->initializerManager); $executor->setLogger(function ($message) use ($output) { $output->writeln(sprintf(' > %s', $message)); }); @@ -137,4 +131,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } + + protected function getPhpcrHelper(): DocumentManagerHelper + { + $helper = parent::getPhpcrHelper(); + \assert($helper instanceof DocumentManagerHelper); + + return $helper; + } } diff --git a/src/Command/MigratorMigrateCommand.php b/src/Command/MigratorMigrateCommand.php index f7402d7a..03b5c18d 100644 --- a/src/Command/MigratorMigrateCommand.php +++ b/src/Command/MigratorMigrateCommand.php @@ -2,21 +2,29 @@ namespace Doctrine\Bundle\PHPCRBundle\Command; -use Symfony\Component\Console\Command\Command; +use Doctrine\Bundle\PHPCRBundle\Migrator\MigratorInterface; +use PHPCR\Util\Console\Command\BaseCommand; +use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; +use Symfony\Component\DependencyInjection\ContainerInterface; -class MigratorMigrateCommand extends Command +class MigratorMigrateCommand extends BaseCommand { - use ContainerAwareTrait; + private const NAME = 'doctrine:phpcr:migrator:migrate'; + + public function __construct( + private ContainerInterface $container + ) { + parent::__construct(self::NAME); + } protected function configure(): void { $this - ->setName('doctrine:phpcr:migrator:migrate') + ->setName(self::NAME) ->setDescription('Migrates PHPCR data.') ->addArgument('migrator_name', InputArgument::OPTIONAL, 'The name of the alias/service to be used to migrate the data.') ->addOption('identifier', null, InputOption::VALUE_REQUIRED, 'Path or UUID of the node to migrate', '/') @@ -31,11 +39,16 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { + $application = $this->getApplication(); + if (!$application instanceof Application) { + throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '. + ($application ? \get_class($application) : null)); + } DoctrineCommandHelper::setApplicationPHPCRSession( - $this->getApplication(), + $application, $input->getOption('session') ); - $session = $this->getHelperSet()->get('phpcr')->getSession(); + $session = $this->getPhpcrSession(); $migrators = $this->container->getParameter('doctrine_phpcr.migrate.migrators'); @@ -53,7 +66,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $migrator = $this->container->get($id); - + if (!$migrator instanceof MigratorInterface) { + throw new \InvalidArgumentException('Looked for a '.MigratorInterface::class.' but found '.($migrator ? \get_class($migrator) : $migrator)); + } $migrator->init($session, $output); $identifier = $input->getOption('identifier'); diff --git a/src/Command/NodeDumpCommand.php b/src/Command/NodeDumpCommand.php index 0267cd2b..5f18b89b 100644 --- a/src/Command/NodeDumpCommand.php +++ b/src/Command/NodeDumpCommand.php @@ -4,10 +4,10 @@ use PHPCR\Util\Console\Command\NodeDumpCommand as BaseDumpCommand; use PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper; +use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -15,34 +15,15 @@ * * @author Daniel Barsotti */ -class NodeDumpCommand extends BaseDumpCommand implements ContainerAwareInterface +class NodeDumpCommand extends BaseDumpCommand { - private ContainerInterface $container; - private PhpcrConsoleDumperHelper $consoleDumper; + private const NAME = 'doctrine:phpcr:node:dump'; - protected function getContainer(): ContainerInterface - { - if (null === $this->container) { - $this->container = $this->getApplication()->getKernel()->getContainer(); - } - - return $this->container; - } - - public function setContainer(ContainerInterface $container = null): void - { - if (!$container) { - unset($this->container); - - return; - } - - $this->container = $container; - } - - public function setConsoleDumper(PhpcrConsoleDumperHelper $consoleDumper): void - { - $this->consoleDumper = $consoleDumper; + public function __construct( + private PhpcrConsoleDumperHelper $consoleDumper, + private int $dumpMaxLineLength + ) { + parent::__construct(self::NAME); } protected function configure(): void @@ -50,7 +31,7 @@ protected function configure(): void parent::configure(); $this - ->setName('doctrine:phpcr:node:dump') + ->setName(self::NAME) ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command') ; } @@ -65,12 +46,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int $helperSet = $application->getHelperSet(); $helperSet->set($this->consoleDumper); - if (!$input->hasOption('max_line_length') - && $this->getContainer()->hasParameter('doctrine_phpcr.dump_max_line_length') - ) { - $input->setOption('max_line_length', $this->getContainer()->getParameter('doctrine_phpcr.dump_max_line_length')); + if (!$input->hasOption('max_line_length')) { + $input->setOption('max_line_length', $this->dumpMaxLineLength); } return parent::execute($input, $output); } + + public function getApplication(): Application + { + $application = parent::getApplication(); + if (!$application instanceof Application) { + throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '. + ($application ? \get_class($application) : null)); + } + + return $application; + } } diff --git a/src/Command/NodeTypeRegisterCommand.php b/src/Command/NodeTypeRegisterCommand.php index ee92080c..71beb62b 100644 --- a/src/Command/NodeTypeRegisterCommand.php +++ b/src/Command/NodeTypeRegisterCommand.php @@ -3,6 +3,7 @@ namespace Doctrine\Bundle\PHPCRBundle\Command; use PHPCR\Util\Console\Command\NodeTypeRegisterCommand as BaseRegisterNodeTypesCommand; +use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -34,14 +35,19 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { + $application = $this->getApplication(); + if (!$application instanceof Application) { + throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '. + ($application ? \get_class($application) : null)); + } + DoctrineCommandHelper::setApplicationPHPCRSession( - $this->getApplication(), + $application, $input->getOption('session'), true ); $definitions = $input->getArgument('cnd-file'); - $application = $this->getApplication(); // if no cnd-files, automatically load from bundles if (0 === \count($definitions)) { diff --git a/src/Command/PhpcrShellCommand.php b/src/Command/PhpcrShellCommand.php index 7263fc06..b5aed3a2 100644 --- a/src/Command/PhpcrShellCommand.php +++ b/src/Command/PhpcrShellCommand.php @@ -4,6 +4,8 @@ use PHPCR\Shell\Console\Application\SessionApplication; use PHPCR\Shell\PhpcrShell; +use PHPCR\Util\Console\Command\BaseCommand; +use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -13,7 +15,7 @@ /** * Wrapper to use this command in the symfony console with multiple sessions. */ -class PhpcrShellCommand extends Command +class PhpcrShellCommand extends BaseCommand { protected function configure(): void { @@ -59,15 +61,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'composer.json file to use this command' ); } - + $application = $this->getApplication(); + if (!$application instanceof Application) { + throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '. + ($application ? \get_class($application) : null)); + } DoctrineCommandHelper::setApplicationPHPCRSession( - $this->getApplication(), + $application, $input->getOption('session') ); $args = $input->getArgument('cmd'); $launchShell = empty($args); - $session = $this->getHelper('phpcr')->getSession(); + $session = $this->getPhpcrSession(); // If no arguments supplied, launch the shell uwith the embedded application if ($launchShell) { @@ -78,8 +84,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int } // else try and run the command using the given input - $application = PhpcrShell::createEmbeddedApplication($session); - $exitCode = $application->runWithStringInput(implode(' ', $args), $output); + $phpcrApplication = PhpcrShell::createEmbeddedApplication($session); + $exitCode = $phpcrApplication->runWithStringInput(implode(' ', $args), $output); // always save the session after running a single command $session->save(); diff --git a/src/Command/RepositoryInitCommand.php b/src/Command/RepositoryInitCommand.php index cc1d6a85..01525090 100644 --- a/src/Command/RepositoryInitCommand.php +++ b/src/Command/RepositoryInitCommand.php @@ -2,12 +2,12 @@ namespace Doctrine\Bundle\PHPCRBundle\Command; +use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager; use Doctrine\ODM\PHPCR\Tools\Console\Command\RegisterSystemNodeTypesCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; /** * Command to collect init operations from any interested bundles. @@ -16,14 +16,20 @@ */ class RepositoryInitCommand extends Command { - use ContainerAwareTrait; + private const NAME = 'doctrine:phpcr:repository:init'; + + public function __construct( + private InitializerManager $initializerManager + ) { + parent::__construct(self::NAME); + } protected function configure(): void { parent::configure(); $this - ->setName('doctrine:phpcr:repository:init') + ->setName(self::NAME) ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command') ->setDescription('Initialize the PHPCR repository.') ->setHelp(<<<'EOT' @@ -47,12 +53,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $command->execute($input, $output); } - $initializerManager = $this->container->get('doctrine_phpcr.initializer_manager'); - $initializerManager->setLoggingClosure(function ($message) use ($output) { + $this->initializerManager->setLoggingClosure(function ($message) use ($output) { $output->writeln($message); }); - $initializerManager->initialize($input->getOption('session')); + $this->initializerManager->initialize($input->getOption('session')); return 0; } diff --git a/src/DependencyInjection/Compiler/DoctrinePhpcrMappingsPass.php b/src/DependencyInjection/Compiler/DoctrinePhpcrMappingsPass.php index d78c64a7..f6f968b8 100644 --- a/src/DependencyInjection/Compiler/DoctrinePhpcrMappingsPass.php +++ b/src/DependencyInjection/Compiler/DoctrinePhpcrMappingsPass.php @@ -2,7 +2,6 @@ namespace Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler; -use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver; use Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver; use Doctrine\ODM\PHPCR\Mapping\Driver\XmlDriver; use Doctrine\ODM\PHPCR\Mapping\Driver\YamlDriver; @@ -122,31 +121,6 @@ public static function createPhpMappingDriver( return new self($driver, $mappings, $managerParameters, $enabledParameter, $aliasMap); } - /** - * @param array $namespaces List of namespaces that are handled with annotation mapping - * @param array $directories List of directories to look for annotated classes - * @param string[] $managerParameters List of parameters that could which object manager name - * your bundle uses. This compiler pass will automatically - * append the parameter name for the default entity manager - * to this list. - * @param string|bool $enabledParameter Service container parameter that must be present to - * enable the mapping. Set to false to not do any check, - * optional. - * @param string[] $aliasMap map of alias to namespace - */ - public static function createAnnotationMappingDriver( - array $namespaces, - array $directories, - array $managerParameters = [], - $enabledParameter = false, - array $aliasMap = [] - ): self { - $reader = new Reference('doctrine_phpcr.odm.metadata.annotation_reader'); - $driver = new Definition(AnnotationDriver::class, [$reader, $directories]); - - return new self($driver, $namespaces, $managerParameters, $enabledParameter, $aliasMap); - } - /** * @param string[] $namespaces List of namespaces that are handled with annotation mapping * @param string[] $directories List of directories to look for annotated classes diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 012c68fb..a11da3ef 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -331,7 +331,6 @@ private function getOdmDocumentManagersNode(): NodeDefinition ->scalarNode('mapping')->defaultValue(true)->end() ->scalarNode('type')->end() ->scalarNode('dir')->end() - ->scalarNode('alias')->end() ->scalarNode('prefix')->end() ->booleanNode('is_bundle')->end() ->end() diff --git a/src/DependencyInjection/DoctrinePHPCRExtension.php b/src/DependencyInjection/DoctrinePHPCRExtension.php index a720f823..6d7f5811 100644 --- a/src/DependencyInjection/DoctrinePHPCRExtension.php +++ b/src/DependencyInjection/DoctrinePHPCRExtension.php @@ -2,6 +2,8 @@ namespace Doctrine\Bundle\PHPCRBundle\DependencyInjection; +use Jackalope\Tools\Console\Command\InitDoctrineDbalCommand as BaseInitDoctrineDbalCommand; +use Jackalope\Tools\Console\Command\JackrabbitCommand as BaseJackrabbitCommand; use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface; use Doctrine\ODM\PHPCR\Document\Generic; use Doctrine\ODM\PHPCR\DocumentManagerInterface; @@ -62,8 +64,14 @@ public function load(array $configs, ContainerBuilder $container) $this->loader->load('phpcr.xml'); $this->loader->load('commands.xml'); + if (class_exists(BaseJackrabbitCommand::class)) { + $this->loader->load('jackrabbit-commands.xml'); + } + if (class_exists(BaseInitDoctrineDbalCommand::class)) { + $this->loader->load('jackalope_doctrine_dbal-commands.xml'); + } - // default values in case no odm is configured. the manager registry needs these variables to be defined. + // default values in case no odm is configured. the manager registry needs these variables to be defined. // if odm is enabled, the parameters are overwritten later in the `loadOdm` section. $container->setParameter('doctrine_phpcr.odm.document_managers', []); $container->setParameter('doctrine_phpcr.odm.default_document_manager', ''); @@ -500,10 +508,8 @@ private function loadOdmDocumentManager(array $documentManager, ContainerBuilder private function loadOdmDocumentManagerMappingInformation(array $documentManager, Definition $odmConfig, ContainerBuilder $container): void { - // reset state of drivers and alias map. They are only used by this methods and children. + // reset state of drivers map. It is only used by this methods and children. $this->drivers = []; - $this->aliasMap = []; - $this->bundleDirs = []; if (!class_exists(Generic::class)) { throw new \RuntimeException('PHPCR ODM is activated in the config but does not seem loadable.'); @@ -513,15 +519,13 @@ private function loadOdmDocumentManagerMappingInformation(array $documentManager $documentManager['mappings']['__PHPCRODM__'] = [ 'dir' => \dirname($class->getFileName()), - 'type' => 'annotation', + 'type' => 'attribute', 'prefix' => 'Doctrine\ODM\PHPCR\Document', 'is_bundle' => false, 'mapping' => true, ]; $this->loadMappingInformation($documentManager, $container); $this->registerMappingDrivers($documentManager, $container); - - $odmConfig->addMethodCall('setDocumentNamespaces', [$this->aliasMap]); } /** diff --git a/src/DoctrinePHPCRBundle.php b/src/DoctrinePHPCRBundle.php index 9b69c103..6ac9d10d 100644 --- a/src/DoctrinePHPCRBundle.php +++ b/src/DoctrinePHPCRBundle.php @@ -5,7 +5,6 @@ use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\InitializerPass; use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\MigratorPass; use Doctrine\Bundle\PHPCRBundle\OptionalCommand\Jackalope\InitDoctrineDbalCommand; -use Doctrine\Bundle\PHPCRBundle\OptionalCommand\Jackalope\JackrabbitCommand; use Doctrine\Bundle\PHPCRBundle\OptionalCommand\ODM\DocumentConvertTranslationCommand; use Doctrine\Bundle\PHPCRBundle\OptionalCommand\ODM\DocumentMigrateClassCommand; use Doctrine\Bundle\PHPCRBundle\OptionalCommand\ODM\InfoDoctrineCommand; @@ -14,12 +13,10 @@ use Doctrine\ODM\PHPCR\Version; use Jackalope\Session; use Jackalope\Tools\Console\Command\InitDoctrineDbalCommand as BaseInitDoctrineDbalCommand; -use Jackalope\Tools\Console\Command\JackrabbitCommand as BaseJackrabbitCommand; use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass; use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\IntrospectableContainerInterface; use Symfony\Component\HttpKernel\Bundle\Bundle; class DoctrinePHPCRBundle extends Bundle @@ -51,9 +48,6 @@ public function registerCommands(Application $application): void $application->add(new DocumentConvertTranslationCommand()); } - if (class_exists(BaseJackrabbitCommand::class)) { - $application->add(new JackrabbitCommand()); - } if (class_exists(BaseInitDoctrineDbalCommand::class)) { $application->add(new InitDoctrineDbalCommand()); } @@ -69,7 +63,7 @@ public function boot(): void $container = &$this->container; $this->autoloader = function ($class) use ($namespace, $dir, &$container) { - if (0 === strpos($class, $namespace)) { + if (str_starts_with($class, $namespace)) { $fileName = str_replace('\\', '', substr($class, \strlen($namespace) + 1)); $file = $dir.\DIRECTORY_SEPARATOR.$fileName.'.php'; @@ -123,10 +117,6 @@ private function clearDocumentManagers(): void } foreach ($this->container->getParameter('doctrine_phpcr.odm.document_managers') as $id) { - if ($this->container instanceof IntrospectableContainerInterface && !$this->container->initialized($id)) { - continue; - } - $this->container->get($id)->clear(); } } @@ -141,10 +131,6 @@ private function closeConnections(): void } foreach ($this->container->getParameter('doctrine_phpcr.sessions') as $id) { - if ($this->container instanceof IntrospectableContainerInterface && !$this->container->initialized($id)) { - continue; - } - $session = $this->container->get($id); if (!$session instanceof Session) { return; diff --git a/src/EventListener/JackalopeDoctrineDbalSchemaListener.php b/src/EventListener/JackalopeDoctrineDbalSchemaListener.php index 5486c0b0..86bd43f7 100644 --- a/src/EventListener/JackalopeDoctrineDbalSchemaListener.php +++ b/src/EventListener/JackalopeDoctrineDbalSchemaListener.php @@ -17,6 +17,9 @@ */ class JackalopeDoctrineDbalSchemaListener { + /** + * @var RepositorySchema + */ private $schema; public function __construct(RepositorySchema $schema) diff --git a/src/Form/DataTransformer/DocumentToPathTransformer.php b/src/Form/DataTransformer/DocumentToPathTransformer.php index 9f16a2cb..28b1fcf6 100644 --- a/src/Form/DataTransformer/DocumentToPathTransformer.php +++ b/src/Form/DataTransformer/DocumentToPathTransformer.php @@ -20,7 +20,7 @@ public function __construct(DocumentManagerInterface $dm) * * @param object $document */ - public function transform($document): ?string + public function transform(mixed $document): ?string { if (null === $document) { return null; @@ -36,7 +36,7 @@ public function transform($document): ?string * * @return object|null returns the document or null if $path is empty */ - public function reverseTransform($path): ?object + public function reverseTransform(mixed $path): ?object { if (!$path) { return null; diff --git a/src/Form/PhpcrOdmTypeGuesser.php b/src/Form/PhpcrOdmTypeGuesser.php index 95a15b36..ffe3d5a7 100644 --- a/src/Form/PhpcrOdmTypeGuesser.php +++ b/src/Form/PhpcrOdmTypeGuesser.php @@ -5,7 +5,7 @@ use Doctrine\Bundle\PHPCRBundle\Form\Type\DocumentType; use Doctrine\Bundle\PHPCRBundle\Form\Type\PathType; use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface; -use Doctrine\ODM\PHPCR\DocumentManager; +use Doctrine\ODM\PHPCR\DocumentManagerInterface; use Doctrine\ODM\PHPCR\Mapping\ClassMetadata; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -208,15 +208,16 @@ public function guessRequired(string $class, string $property): ?ValueGuess return new ValueGuess(false, Guess::MEDIUM_CONFIDENCE); } - if ($metadata->hasAssociation($property)) { - if ($property === $metadata->parentMapping - && ClassMetadata::GENERATOR_TYPE_ASSIGNED !== $metadata->idGenerator - ) { - return new ValueGuess(true, Guess::HIGH_CONFIDENCE); - } - - return new ValueGuess(false, Guess::LOW_CONFIDENCE); + if (!$metadata->hasAssociation($property)) { + return null; + } + if ($property === $metadata->parentMapping + && ClassMetadata::GENERATOR_TYPE_ASSIGNED !== $metadata->idGenerator + ) { + return new ValueGuess(true, Guess::HIGH_CONFIDENCE); } + + return new ValueGuess(false, Guess::LOW_CONFIDENCE); } public function guessPattern(string $class, string $property): ?ValueGuess @@ -225,7 +226,7 @@ public function guessPattern(string $class, string $property): ?ValueGuess } /** - * @return array{0: ClassMetadata, 1: DocumentManager}|null + * @return array{0: ClassMetadata, 1: DocumentManagerInterface}|null */ private function getMetadata(string $class): ?array { diff --git a/src/Initializer/InitializerManager.php b/src/Initializer/InitializerManager.php index f1b33192..6561d87b 100644 --- a/src/Initializer/InitializerManager.php +++ b/src/Initializer/InitializerManager.php @@ -19,6 +19,11 @@ class InitializerManager private ManagerRegistryInterface $registry; private ?\Closure $loggingClosure = null; + /** + * @var InitializerInterface[] + */ + private array $sortedInitializers; + public function __construct(ManagerRegistryInterface $registry) { $this->registry = $registry; @@ -58,10 +63,10 @@ public function initialize(string $sessionName = null): void // handle specified session if present if ($sessionName) { - if (\in_array(SessionAwareInitializerInterface::class, class_implements($initializer))) { + if ($initializer instanceof SessionAwareInitializerInterface) { $initializer->setSessionName($sessionName); } elseif ($loggingClosure) { - $loggingClosure(sprintf('Initializer "%s" does not implement SessionAwareInitializerInterface, "session" parameter will be ommitted.', $initializer->getName())); + $loggingClosure(sprintf('Initializer "%s" does not implement SessionAwareInitializerInterface, "session" parameter will be omitted.', $initializer->getName())); } } diff --git a/src/ManagerRegistry.php b/src/ManagerRegistry.php index e6f682cc..77ded2a4 100644 --- a/src/ManagerRegistry.php +++ b/src/ManagerRegistry.php @@ -58,22 +58,34 @@ public function getAliasNamespace($alias): string public function getManager($name = null): DocumentManagerInterface { - return parent::getManager($name); + $dm = parent::getManager($name); + \assert($dm instanceof DocumentManagerInterface); + + return $dm; } public function resetManager($name = null): DocumentManagerInterface { - return parent::resetManager($name); + $dm = parent::resetManager($name); + \assert($dm instanceof DocumentManagerInterface); + + return $dm; } public function getManagerForClass($class = null): ?DocumentManagerInterface { - return parent::getManagerForClass($class); + $dm = parent::getManagerForClass($class); + \assert(null === $dm || $dm instanceof DocumentManagerInterface); + + return $dm; } public function getConnection($name = null): SessionInterface { - return parent::getConnection($name); + $conn = parent::getConnection($name); + \assert($conn instanceof SessionInterface); + + return $conn; } /** @@ -92,6 +104,9 @@ public function getAdminConnection(?string $name = null): SessionInterface throw new \InvalidArgumentException(sprintf('Doctrine %s Connection named "%s" does not exist.', $this->getName(), $name)); } - return $this->getService($serviceName); + $connection = $this->getService($serviceName); + \assert($connection instanceof SessionInterface); + + return $connection; } } diff --git a/src/OptionalCommand/Jackalope/InitDoctrineDbalCommand.php b/src/OptionalCommand/Jackalope/InitDoctrineDbalCommand.php index e53c4930..ef6f42d3 100644 --- a/src/OptionalCommand/Jackalope/InitDoctrineDbalCommand.php +++ b/src/OptionalCommand/Jackalope/InitDoctrineDbalCommand.php @@ -4,6 +4,7 @@ use Doctrine\Bundle\PHPCRBundle\Command\DoctrineCommandHelper; use Jackalope\Tools\Console\Command\InitDoctrineDbalCommand as BaseInitDoctrineDbalCommand; +use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -26,6 +27,11 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { $application = $this->getApplication(); + if (!$application instanceof Application) { + throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '. + ($application ? \get_class($application) : null)); + } + $sessionName = $input->getOption('session'); if (empty($sessionName)) { $container = $application->getKernel()->getContainer(); diff --git a/src/OptionalCommand/Jackalope/JackrabbitCommand.php b/src/OptionalCommand/Jackalope/JackrabbitCommand.php index c4968cb6..6dd4bcfa 100644 --- a/src/OptionalCommand/Jackalope/JackrabbitCommand.php +++ b/src/OptionalCommand/Jackalope/JackrabbitCommand.php @@ -5,47 +5,34 @@ use Jackalope\Tools\Console\Command\JackrabbitCommand as BaseJackrabbitCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Wrapper to use this command in the symfony console with multiple sessions. * * @author Daniel Barsotti */ -class JackrabbitCommand extends BaseJackrabbitCommand implements ContainerAwareInterface +class JackrabbitCommand extends BaseJackrabbitCommand { - /** - * @var ContainerInterface - */ - private $container; + private const NAME = 'doctrine:phpcr:jackrabbit'; - protected function getContainer(): ContainerInterface - { - if (null === $this->container) { - $this->container = $this->getApplication()->getKernel()->getContainer(); - } - - return $this->container; + public function __construct( + private string $jackrabbitJar, + private string $workspaceDir, + ) { + parent::__construct(self::NAME); } - - public function setContainer(ContainerInterface $container = null): void - { - $this->container = $container; - } - protected function configure(): void { parent::configure(); $this - ->setName('doctrine:phpcr:jackrabbit') + ->setName(self::NAME) ->setHelp(<<<'EOF' The doctrine:phpcr:jackrabbit command allows to have a minimal control on the Jackrabbit server from within a Symfony 2 command. If the jackrabbit_jar option is set, it will be used as the Jackrabbit server jar file. -Otherwise you will have to set the doctrine_phpcr.jackrabbit_jar config parameter to a valid Jackrabbit +Otherwise, you will have to set the doctrine_phpcr.jackrabbit_jar config parameter to a valid Jackrabbit server jar file. EOF ) @@ -54,13 +41,8 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { - if ($this->getContainer()->hasParameter('doctrine_phpcr.jackrabbit_jar')) { - $this->setJackrabbitPath($this->getContainer()->getParameter('doctrine_phpcr.jackrabbit_jar')); - } - - if ($this->getContainer()->hasParameter('doctrine_phpcr.workspace_dir')) { - $this->setWorkspaceDir($this->getContainer()->getParameter('doctrine_phpcr.workspace_dir')); - } + $this->setJackrabbitPath($this->jackrabbitJar); + $this->setWorkspaceDir($this->workspaceDir); return parent::execute($input, $output); } diff --git a/src/Resources/config/commands.xml b/src/Resources/config/commands.xml index 88fb39d6..58cb8ed2 100644 --- a/src/Resources/config/commands.xml +++ b/src/Resources/config/commands.xml @@ -6,25 +6,20 @@ - - - + - - - + + + %doctrine_phpcr.dump_max_line_length% - - - @@ -48,9 +43,7 @@ - - - + diff --git a/src/Resources/config/jackalope_doctrine_dbal-commands.xml b/src/Resources/config/jackalope_doctrine_dbal-commands.xml new file mode 100644 index 00000000..e031e966 --- /dev/null +++ b/src/Resources/config/jackalope_doctrine_dbal-commands.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/src/Resources/config/jackrabbit-commands.xml b/src/Resources/config/jackrabbit-commands.xml new file mode 100644 index 00000000..820799bf --- /dev/null +++ b/src/Resources/config/jackrabbit-commands.xml @@ -0,0 +1,15 @@ + + + + + + + %doctrine_phpcr.jackrabbit_jar% + %doctrine_phpcr.workspace_dir% + + + + + diff --git a/src/Resources/config/odm.xml b/src/Resources/config/odm.xml index 72e36b4c..65c24225 100644 --- a/src/Resources/config/odm.xml +++ b/src/Resources/config/odm.xml @@ -23,7 +23,6 @@ Doctrine\Bundle\PHPCRBundle\Mapping\Driver\YamlDriver Doctrine\Persistence\Mapping\Driver\StaticPHPDriver Doctrine\Persistence\Mapping\Driver\MappingDriverChain - Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver @@ -42,7 +41,6 @@ - container = $container; + public function __construct( + private ManagerRegistryInterface $managerRegistry, + private InitializerManager $initializerManager, + ) { } public function getRegistry(): ManagerRegistryInterface { - return $this->container->get('doctrine_phpcr'); + return $this->managerRegistry; } public function getDocumentManager(string $managerName = null): DocumentManagerInterface @@ -53,7 +52,7 @@ public function purgeRepository(bool $initialize = false): void */ public function loadFixtures(array $classNames, bool $initialize = false): void { - $loader = new ContainerAwareLoader($this->container); + $loader = new Loader(); foreach ($classNames as $className) { $this->loadFixture($loader, $className); @@ -101,7 +100,7 @@ private function getExecutor(bool $initialize = false): PHPCRExecutor return $this->executor; } - $initializerManager = $initialize ? $this->container->get('doctrine_phpcr.initializer_manager') : null; + $initializerManager = $initialize ? $this->initializerManager : null; $purger = new PHPCRPurger(); $executor = new PHPCRExecutor($this->getDocumentManager(), $purger, $initializerManager); $referenceRepository = new ProxyReferenceRepository($this->getDocumentManager()); diff --git a/tests/Fixtures/App/DataFixtures/PHPCR/LoadData.php b/tests/Fixtures/App/DataFixtures/PHPCR/LoadData.php index 84c22efb..6d30d9dd 100644 --- a/tests/Fixtures/App/DataFixtures/PHPCR/LoadData.php +++ b/tests/Fixtures/App/DataFixtures/PHPCR/LoadData.php @@ -20,9 +20,6 @@ class LoadData implements FixtureInterface { - /** - * @param DocumentManager $manager - */ public function load(ObjectManager $manager): void { $base = new Generic(); diff --git a/tests/Fixtures/App/Document/ReferrerDocument.php b/tests/Fixtures/App/Document/ReferrerDocument.php index 9e5c2de7..9094802d 100644 --- a/tests/Fixtures/App/Document/ReferrerDocument.php +++ b/tests/Fixtures/App/Document/ReferrerDocument.php @@ -13,36 +13,24 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCR\Document() - */ +#[PHPCR\Document] class ReferrerDocument { - /** - * @PHPCR\Id(strategy="assigned") - */ + #[PHPCR\Id(strategy: 'assigned')] public string $id; - /** - * @PHPCR\ReferenceOne() - */ + #[PHPCR\ReferenceOne] protected $single; - /** - * @PHPCR\ReferenceMany() - */ + #[PHPCR\ReferenceMany] protected Collection $documents; - /** - * @PHPCR\ReferenceOne(targetDocument="Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Document\TestDocument") - */ + #[PHPCR\ReferenceOne(targetDocument: TestDocument::class)] protected $testDocument; - /** - * @PHPCR\ReferenceMany(targetDocument="Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Document\TestDocument") - */ + #[PHPCR\ReferenceMany(targetDocument: TestDocument::class)] protected Collection $testDocuments; public function __construct() diff --git a/tests/Fixtures/App/Document/TestDocument.php b/tests/Fixtures/App/Document/TestDocument.php index 3532cad7..292f7d84 100644 --- a/tests/Fixtures/App/Document/TestDocument.php +++ b/tests/Fixtures/App/Document/TestDocument.php @@ -4,115 +4,70 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; -use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR; +use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCR; -/** - * @PHPCR\Document(referenceable=true) - */ +#[PHPCR\Document(referenceable: true)] class TestDocument { - /** - * @PHPCR\Id() - */ + #[PHPCR\Id] public string $id; - /** - * @PHPCR\ParentDocument() - */ + #[PHPCR\ParentDocument] public $parent; - /** - * @PHPCR\Nodename() - */ + #[PHPCR\Nodename] public string $nodename; - /** - * @PHPCR\Uuid - */ + #[PHPCR\Uuid] public string $uuid; - /** - * @PHPCR\Child() - */ + #[PHPCR\Child] public $child; - /** - * @PHPCR\Children() - */ + #[PHPCR\Children] protected Collection $children; - /** - * @PHPCR\Referrers( - * referringDocument="Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Document\ReferrerDocument", - * referencedBy="documents" - * ) - */ + #[PHPCR\Referrers(referencedBy: 'documents', referringDocument: ReferrerDocument::class)] protected Collection $referrers; - /** - * @PHPCR\MixedReferrers() - */ + #[PHPCR\MixedReferrers] protected Collection $mixedReferrers; - /** - * @PHPCR\Field(type="boolean") - */ + #[PHPCR\Field(type: 'boolean')] public bool $bool; - /** - * @PHPCR\Field(type="date") - */ + #[PHPCR\Field(type: 'date')] public \DateTimeInterface $date; - /** - * @PHPCR\Field(type="string") - */ + #[PHPCR\Field(type: 'string')] public string $text; - /** - * @PHPCR\Field(type="double") - */ + #[PHPCR\Field(type: 'double')] public float $number; - /** - * @PHPCR\Field(type="long") - */ + #[PHPCR\Field(type: 'long')] public int $long; - /** - * @PHPCR\Field(type="int") - */ + #[PHPCR\Field(type: 'int')] public int $integer; - /** - * @PHPCR\Field(type="boolean", multivalue=true, nullable=true) - */ - public array $mbool; + #[PHPCR\Field(type: 'boolean', multivalue: true, nullable: true)] + public ?array $mbool; - /** - * @PHPCR\Field(type="date", multivalue=true, nullable=true) - */ - public array $mdate; + #[PHPCR\Field(type: 'date', multivalue: true, nullable: true)] + public ?array $mdate; - /** - * @PHPCR\Field(type="string", multivalue=true, nullable=true) - */ - public array $mtext; + #[PHPCR\Field(type: 'string', multivalue: true, nullable: true)] + public ?array $mtext; - /** - * @PHPCR\Field(type="double", multivalue=true, nullable=true) - */ - public array $mnumber; + #[PHPCR\Field(type: 'double', multivalue: true, nullable: true)] + public ?array $mnumber; - /** - * @PHPCR\Field(type="long", multivalue=true, nullable=true) - */ - public array $mlong; + #[PHPCR\Field(type: 'long', multivalue: true, nullable: true)] + public ?array $mlong; - /** - * @PHPCR\Field(type="int", multivalue=true, nullable=true) - */ - public array $minteger; + #[PHPCR\Field(type: 'int', multivalue: true, nullable: true)] + public ?array $minteger; public function __construct() { diff --git a/tests/Fixtures/App/Kernel.php b/tests/Fixtures/App/Kernel.php index 41548279..74b2b65e 100644 --- a/tests/Fixtures/App/Kernel.php +++ b/tests/Fixtures/App/Kernel.php @@ -32,7 +32,7 @@ public function registerBundles(): iterable } } - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load(__DIR__.'/config/config.php'); } diff --git a/tests/Fixtures/App/config/doctrine.yaml b/tests/Fixtures/App/config/doctrine.yaml index fcfcd79f..6ce3bef7 100644 --- a/tests/Fixtures/App/config/doctrine.yaml +++ b/tests/Fixtures/App/config/doctrine.yaml @@ -23,7 +23,7 @@ doctrine_phpcr: fr: [en, de] mappings: test_additional: - type: annotation + type: attribute prefix: Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Document dir: "%kernel.project_dir%/Document" is_bundle: false diff --git a/tests/Fixtures/App/config/framework.yaml b/tests/Fixtures/App/config/framework.yaml index 2563d981..0fdd3775 100644 --- a/tests/Fixtures/App/config/framework.yaml +++ b/tests/Fixtures/App/config/framework.yaml @@ -1,6 +1,5 @@ framework: secret: test - annotations: ~ property_access: ~ test: ~ form: ~ diff --git a/tests/Fixtures/fixtures/config/single.php b/tests/Fixtures/fixtures/config/single.php index 528c890c..4c565712 100644 --- a/tests/Fixtures/fixtures/config/single.php +++ b/tests/Fixtures/fixtures/config/single.php @@ -38,7 +38,6 @@ 'mapping' => true, 'type' => null, 'dir' => null, - 'alias' => null, 'prefix' => null, 'is-bundle' => null, ], diff --git a/tests/Fixtures/fixtures/config/single.xml b/tests/Fixtures/fixtures/config/single.xml index 6271b319..c1ba2df8 100644 --- a/tests/Fixtures/fixtures/config/single.xml +++ b/tests/Fixtures/fixtures/config/single.xml @@ -43,7 +43,6 @@ mapping="true" type="null" dir="null" - alias="null" prefix="null" is-bundle="null" /> diff --git a/tests/Fixtures/fixtures/config/single.yml b/tests/Fixtures/fixtures/config/single.yml index fbdf441b..48ef201f 100644 --- a/tests/Fixtures/fixtures/config/single.yml +++ b/tests/Fixtures/fixtures/config/single.yml @@ -26,7 +26,6 @@ doctrine_phpcr: mapping: true type: ~ dir: ~ - alias: ~ prefix: ~ is_bundle: ~ auto_generate_proxy_classes: true diff --git a/tests/Functional/BaseTestCase.php b/tests/Functional/BaseTestCase.php index 0e8b1009..d701f193 100644 --- a/tests/Functional/BaseTestCase.php +++ b/tests/Functional/BaseTestCase.php @@ -17,8 +17,9 @@ protected function getRepositoryManager(): RepositoryManager if (!self::$kernel->getContainer()) { self::$kernel->boot(); } + $container = self::getTestContainer(); - return new RepositoryManager(self::getTestContainer()); + return new RepositoryManager($container->get('doctrine_phpcr'), $container->get('doctrine_phpcr.initializer_manager')); } protected function assertResponseSuccess(Response $response): void diff --git a/tests/Unit/DependencyInjection/ConfigurationTest.php b/tests/Unit/DependencyInjection/ConfigurationTest.php index 5e4a1bc4..0c57b435 100644 --- a/tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/tests/Unit/DependencyInjection/ConfigurationTest.php @@ -93,7 +93,6 @@ public function configurations(): array 'mapping' => true, 'type' => null, 'dir' => null, - 'alias' => null, 'prefix' => null, 'is_bundle' => true, ],