Skip to content

Commit

Permalink
build with php 8.3 and symfony 7
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Dec 2, 2023
1 parent 2a941be commit e387f0b
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 94 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: "7.4"
phpunit-version: "8.5"
dependencies: "lowest"

- php-version: "7.4"
phpunit-version: "8.5"
- php-version: "8.0"
phpunit-version: "9.5"
phpunit-flags: "-v --coverage-text"
symfony-version: "^5.4"
symfony-version: "6.0.*"

- php-version: "8.0"
phpunit-version: "9.5"
Expand All @@ -36,9 +32,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"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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.
Expand Down
43 changes: 24 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,39 @@
],
"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"
"jackalope/jackalope-jackrabbit": "^2.0",
"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",
"doctrine/phpcr-odm": "dev-symfony-7 as 2.0",
"doctrine/orm": "^2.0 || ^3.0",
"jackalope/jackalope-doctrine-dbal": "^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/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": "^4.4 || ^5.0 || ^6.0",
"symfony/form": "^5.4 || ^6.0",
"symfony/monolog-bridge": "^5.4 || ^6.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": "^5.4 || ^6.0",
"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/phpunit-bridge": "^5.4 || ^6.0 || ^7.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.*",
Expand Down Expand Up @@ -78,5 +82,6 @@
"Doctrine\\Bundle\\PHPCRBundle\\Tests\\": "tests/"
}
},
"minimum-stability": "beta"
"prefer-stable": true,
"minimum-stability": "dev"
}
4 changes: 3 additions & 1 deletion src/CacheWarmer/UniqueNodeTypeCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ public function isOptional(): bool
return true;
}

public function warmUp($cacheDir): void
public function warmUp($cacheDir): array
{
$helper = new UniqueNodeTypeHelper();

foreach ($this->registry->getManagers() as $documentManager) {
$helper->checkNodeTypeMappings($documentManager);
}

return [];
}
}
43 changes: 23 additions & 20 deletions src/Command/LoadFixtureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

use Doctrine\Bundle\PHPCRBundle\DataFixtures\PHPCRExecutor;
use Doctrine\Common\DataFixtures\Purger\PHPCRPurger;
use Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper;
use InvalidArgumentException;
use PHPCR\Util\Console\Command\BaseCommand;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\DialogHelper;
use Symfony\Component\Console\Helper\QuestionHelper;
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.
Expand All @@ -24,7 +24,7 @@
* @author Jonathan H. Wage <[email protected]>
* @author Daniel Leech <[email protected]>
*/
class LoadFixtureCommand extends Command
class LoadFixtureCommand extends BaseCommand
{
use ContainerAwareTrait;

Expand Down Expand Up @@ -65,28 +65,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 = '<question>Careful, database will be purged. Do you want to continue Y/N ?</question>';
$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;
}
Expand All @@ -96,8 +92,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) {
Expand Down Expand Up @@ -137,4 +132,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int

return 0;
}

protected function getPhpcrHelper(): DocumentManagerHelper
{
$helper = parent::getPhpcrHelper();
\assert($helper instanceof DocumentManagerHelper);

return $helper;
}
}
19 changes: 14 additions & 5 deletions src/Command/MigratorMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

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;

class MigratorMigrateCommand extends Command
class MigratorMigrateCommand extends BaseCommand
{
use ContainerAwareTrait;

Expand All @@ -31,11 +33,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');

Expand All @@ -53,7 +60,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');
Expand Down
14 changes: 13 additions & 1 deletion src/Command/NodeDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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;
Expand All @@ -17,7 +18,7 @@
*/
class NodeDumpCommand extends BaseDumpCommand implements ContainerAwareInterface
{
private ContainerInterface $container;
private ?ContainerInterface $container = null;
private PhpcrConsoleDumperHelper $consoleDumper;

protected function getContainer(): ContainerInterface
Expand Down Expand Up @@ -73,4 +74,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int

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;
}
}
10 changes: 8 additions & 2 deletions src/Command/NodeTypeRegisterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down
18 changes: 12 additions & 6 deletions src/Command/PhpcrShellCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/DependencyInjection/DoctrinePHPCRExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ private function loadOdmDocumentManagerMappingInformation(array $documentManager
// reset state of drivers and alias map. They are 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.');
Expand Down
Loading

0 comments on commit e387f0b

Please sign in to comment.