From b833f68dfbfbbaf15812b421d24b9c755706b2aa Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 3 Apr 2024 10:37:30 +0200 Subject: [PATCH] php-cs-fixer and phpstan --- .github/workflows/static.yml | 47 +++++++++++++++++++ .github/workflows/test-application.yaml | 10 +--- .gitignore | 6 ++- .php-cs-fixer.dist.php | 19 ++++++++ .php_cs | 9 ---- composer.json | 8 +++- phpstan.neon.dist | 15 ++++++ src/Command/DoctrineCommandHelper.php | 6 +-- src/Command/NodeDumpCommand.php | 1 - src/Command/PhpcrShellCommand.php | 2 +- src/DataCollector/PHPCRDataCollector.php | 6 +-- src/DataCollector/StopWatchLogger.php | 2 +- src/DataFixtures/PHPCRExecutor.php | 4 +- .../DoctrinePHPCRExtension.php | 8 ++-- .../ChoiceList/PhpcrOdmQueryBuilderLoader.php | 2 +- src/Form/PhpcrOdmTypeGuesser.php | 6 +-- src/Form/Type/PHPCRReferenceType.php | 2 +- src/Initializer/InitializerManager.php | 4 +- src/ManagerRegistry.php | 5 +- .../Jackalope/JackrabbitCommand.php | 1 + .../ODM/LoadFixtureCommand.php | 3 +- src/Test/RepositoryManager.php | 2 +- .../Constraints/ValidPhpcrOdmValidator.php | 3 ++ .../App/DataFixtures/PHPCR/LoadData.php | 5 +- .../App/Document/ReferrerDocument.php | 9 ---- tests/Fixtures/App/config/bundles.php | 12 ++--- .../Command/NodeDumpCommandTest.php | 2 +- .../PhpcrOdmQueryBuilderLoaderTest.php | 2 + .../Functional/Form/Type/DocumentTypeTest.php | 2 + .../DocumentToPathTransformerTest.php | 2 +- .../PHPCRNodeToPathTransformerTest.php | 2 +- .../PHPCRNodeToUuidTransformerTest.php | 2 +- .../Unit/Form/Type/PHPCRReferenceTypeTest.php | 2 +- tests/Unit/Form/Type/PathTypeTest.php | 2 +- .../Initializer/GenericInitializerTest.php | 5 +- 35 files changed, 145 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/static.yml create mode 100644 .php-cs-fixer.dist.php delete mode 100644 .php_cs create mode 100644 phpstan.neon.dist diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 00000000..936eb333 --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,47 @@ +name: Static analysis + +on: + push: + branches: + - '[0-9]+.x' + - '[0-9]+.[0-9]+' + - '[0-9]+.[0-9]+.x' + pull_request: + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-latest + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + extensions: "curl,dom,json,xml,dom" + coverage: none + + - name: Checkout code + uses: actions/checkout@v3 + + # have to install phpstan ourselves here, the phpstan-ga fails at composer install with weird errors + - name: Install phpstan + run: | + composer require --no-update jackalope/jackalope-doctrine-dbal jackalope/jackalope-jackrabbit phpstan/phpstan + composer update + + - name: PHPStan + run: vendor/bin/phpstan analyze --no-progress + + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: PHP-CS-Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --dry-run --diff diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml index fbe756da..35408487 100644 --- a/.github/workflows/test-application.yaml +++ b/.github/workflows/test-application.yaml @@ -20,18 +20,14 @@ jobs: matrix: include: - php-version: "8.1" - phpunit-version: "9.5" phpunit-flags: "-v --coverage-text" symfony-version: "6.0.*" - php-version: "8.1" - phpunit-version: "9.5" - php-version: "8.2" - phpunit-version: "9.5" - php-version: "8.3" - phpunit-version: "9.5" symfony-version: "7.*" steps: @@ -65,8 +61,4 @@ jobs: run: "tests/phpcr_odm_doctrine_dbal.sh" - name: "Execute test cases" - run: | - if [[ $SYMFONY_PHPUNIT_VERSION == '' ]]; then unset SYMFONY_PHPUNIT_VERSION; fi; - vendor/bin/simple-phpunit ${{ matrix.phpunit-flags }} - env: - SYMFONY_PHPUNIT_VERSION: "${{ matrix.phpunit-version }}" + run: vendor/bin/phpunit ${{ matrix.phpunit-flags }} diff --git a/.gitignore b/.gitignore index 9aa59935..eece93dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ composer.lock -vendor +phpunit.xml !tests/Fixtures/App/var/.gitempty tests/Fixtures/App/var -/.php_cs.cache +vendor +.phpunit.result.cache +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 00000000..13c93dbc --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,19 @@ +in(__DIR__.'/src') + ->in(__DIR__.'/tests') + ->exclude(__DIR__.'/tests/Fixtures/App/var') + ->name('*.php') +; + +$config = new PhpCsFixer\Config(); + +return $config + ->setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + 'single_line_throw' => false, + ]) + ->setFinder($finder) +; diff --git a/.php_cs b/.php_cs deleted file mode 100644 index 4fc43c3d..00000000 --- a/.php_cs +++ /dev/null @@ -1,9 +0,0 @@ -setUsingCache(true) -; diff --git a/composer.json b/composer.json index 4a7823d1..a1b2f53a 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,12 @@ "doctrine/orm": "^2.0 || ^3.0", "jackalope/jackalope-doctrine-dbal": "^2.0", "matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0", + "phpcr/phpcr-shell": "^1.6", + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-doctrine": "^1.3", + "phpstan/phpstan-phpunit": "^1.3", + "phpstan/phpstan-symfony": "^1.3", + "phpunit/phpunit": "^9.5", "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", @@ -50,7 +56,7 @@ "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/stopwatch": "^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", diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..c4875e9e --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,15 @@ +includes: + - vendor/phpstan/phpstan-doctrine/extension.neon + - vendor/phpstan/phpstan-doctrine/rules.neon + - vendor/phpstan/phpstan-phpunit/extension.neon + - vendor/phpstan/phpstan-symfony/extension.neon + - vendor/phpstan/phpstan-symfony/rules.neon +parameters: + level: 2 + paths: + - src/ + - tests/ + excludePaths: + - tests/Fixtures/App/var/ + - tests/Fixtures/fixtures/config/ + - tests/Fixtures/App/config/ diff --git a/src/Command/DoctrineCommandHelper.php b/src/Command/DoctrineCommandHelper.php index c2617f2a..94b6a49f 100644 --- a/src/Command/DoctrineCommandHelper.php +++ b/src/Command/DoctrineCommandHelper.php @@ -29,13 +29,13 @@ public static function setApplicationConnection(Application $application, string { $connectionService = sprintf('doctrine_phpcr.jackalope_doctrine_dbal.%s_connection', $sessionName); $helperSet = $application->getHelperSet(); - $helperSet->set(new DoctrineDBALHelper($application->getKernel()->getContainer()->get($connectionService))); + $helperSet->set(new DoctrineDbalHelper($application->getKernel()->getContainer()->get($connectionService))); } /** * Prepare the DBAL connection and the PHPCR session. */ - public static function setApplicationPHPCRSession(Application $application, string $sessionName = null, bool $admin = false): void + public static function setApplicationPHPCRSession(Application $application, ?string $sessionName = null, bool $admin = false): void { $registry = self::getRegistry($application); $session = $admin ? $registry->getAdminConnection($sessionName) : $registry->getConnection($sessionName); @@ -52,7 +52,7 @@ public static function setApplicationPHPCRSession(Application $application, stri || $session->getTransport() instanceof DbalLoggingClient ) ) { - $helperSet->set(new DoctrineDBALHelper($session->getTransport()->getConnection())); + $helperSet->set(new DoctrineDbalHelper($session->getTransport()->getConnection())); } } diff --git a/src/Command/NodeDumpCommand.php b/src/Command/NodeDumpCommand.php index 5f18b89b..631f76ae 100644 --- a/src/Command/NodeDumpCommand.php +++ b/src/Command/NodeDumpCommand.php @@ -8,7 +8,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Wrapper to use this command in the symfony console with multiple sessions. diff --git a/src/Command/PhpcrShellCommand.php b/src/Command/PhpcrShellCommand.php index b5aed3a2..e97f2259 100644 --- a/src/Command/PhpcrShellCommand.php +++ b/src/Command/PhpcrShellCommand.php @@ -75,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $launchShell = empty($args); $session = $this->getPhpcrSession(); - // If no arguments supplied, launch the shell uwith the embedded application + // If no arguments supplied, launch the shell with the embedded application if ($launchShell) { $shell = PhpcrShell::createEmbeddedShell($session); $exitCode = $shell->run(); diff --git a/src/DataCollector/PHPCRDataCollector.php b/src/DataCollector/PHPCRDataCollector.php index 63d6ff83..ab3ac334 100644 --- a/src/DataCollector/PHPCRDataCollector.php +++ b/src/DataCollector/PHPCRDataCollector.php @@ -38,7 +38,7 @@ public function __construct(ManagerRegistryInterface $registry) $this->managers = $registry->getManagerNames(); } - public function collect(Request $request, Response $response, \Throwable $exception = null): void + public function collect(Request $request, Response $response, ?\Throwable $exception = null): void { $this->collectInternal($request, $response); } @@ -114,8 +114,6 @@ private function sanitizeCall($call) * The return value is an array with the sanitized value and a boolean * indicating if the original value was kept (allowing to use the sanitized * value to explain the call). - * - * @param mixed $var */ private function sanitizeParam($var): array { @@ -155,7 +153,7 @@ private function sanitizeParam($var): array return [$var, true]; } - protected function collectInternal(Request $request, Response $response, \Throwable $exception = null): void + protected function collectInternal(Request $request, Response $response, ?\Throwable $exception = null): void { $calls = []; foreach ($this->loggers as $name => $logger) { diff --git a/src/DataCollector/StopWatchLogger.php b/src/DataCollector/StopWatchLogger.php index e8a0fd7c..d4fb895a 100644 --- a/src/DataCollector/StopWatchLogger.php +++ b/src/DataCollector/StopWatchLogger.php @@ -18,7 +18,7 @@ public function __construct(?Stopwatch $stopwatch = null) $this->stopwatch = $stopwatch; } - public function startCall($method, array $params = null, array $env = null): void + public function startCall($method, ?array $params = null, ?array $env = null): void { if (null !== $this->stopwatch) { $this->stopwatch->start('doctrine_phpcr', 'doctrine_phpcr'); diff --git a/src/DataFixtures/PHPCRExecutor.php b/src/DataFixtures/PHPCRExecutor.php index 2dbdbc76..a818a6ac 100644 --- a/src/DataFixtures/PHPCRExecutor.php +++ b/src/DataFixtures/PHPCRExecutor.php @@ -18,8 +18,8 @@ final class PHPCRExecutor extends BasePHPCRExecutor public function __construct( DocumentManagerInterface $dm, - PHPCRPurger $purger = null, - InitializerManager $initializerManager = null + ?PHPCRPurger $purger = null, + ?InitializerManager $initializerManager = null ) { parent::__construct($dm, $purger); diff --git a/src/DependencyInjection/DoctrinePHPCRExtension.php b/src/DependencyInjection/DoctrinePHPCRExtension.php index 743ff2cd..cb9c002b 100644 --- a/src/DependencyInjection/DoctrinePHPCRExtension.php +++ b/src/DependencyInjection/DoctrinePHPCRExtension.php @@ -2,12 +2,12 @@ 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; use Jackalope\Session; +use Jackalope\Tools\Console\Command\InitDoctrineDbalCommand as BaseInitDoctrineDbalCommand; +use Jackalope\Tools\Console\Command\JackrabbitCommand as BaseJackrabbitCommand; use PHPCR\SessionInterface; use Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension; use Symfony\Component\Cache\Adapter\ArrayAdapter; @@ -71,7 +71,7 @@ public function load(array $configs, ContainerBuilder $container) $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', ''); @@ -588,7 +588,7 @@ protected function getMappingObjectDefaultName(): string return 'Document'; } - protected function getMappingResourceConfigDirectory(string $bundleDir = null): string + protected function getMappingResourceConfigDirectory(?string $bundleDir = null): string { return 'Resources/config/doctrine'; } diff --git a/src/Form/ChoiceList/PhpcrOdmQueryBuilderLoader.php b/src/Form/ChoiceList/PhpcrOdmQueryBuilderLoader.php index 8df2014f..2a3b26a1 100644 --- a/src/Form/ChoiceList/PhpcrOdmQueryBuilderLoader.php +++ b/src/Form/ChoiceList/PhpcrOdmQueryBuilderLoader.php @@ -24,7 +24,7 @@ final class PhpcrOdmQueryBuilderLoader implements EntityLoaderInterface /** * @param QueryBuilder|\Closure $queryBuilder */ - public function __construct($queryBuilder, DocumentManagerInterface $manager = null, string $class = null) + public function __construct($queryBuilder, ?DocumentManagerInterface $manager = null, ?string $class = null) { // If a query builder was passed, it must be a closure or QueryBuilder // instance diff --git a/src/Form/PhpcrOdmTypeGuesser.php b/src/Form/PhpcrOdmTypeGuesser.php index ffe3d5a7..72504628 100644 --- a/src/Form/PhpcrOdmTypeGuesser.php +++ b/src/Form/PhpcrOdmTypeGuesser.php @@ -67,9 +67,9 @@ public function guessType(string $class, string $property): ?TypeGuess case 'referrers': return new TypeGuess(DocumentType::class, [ - 'class' => $mapping['referringDocument'], - 'multiple' => true, - ], + 'class' => $mapping['referringDocument'], + 'multiple' => true, + ], Guess::HIGH_CONFIDENCE ); diff --git a/src/Form/Type/PHPCRReferenceType.php b/src/Form/Type/PHPCRReferenceType.php index 70cd45d0..12278a13 100644 --- a/src/Form/Type/PHPCRReferenceType.php +++ b/src/Form/Type/PHPCRReferenceType.php @@ -22,7 +22,7 @@ class PHPCRReferenceType extends AbstractType { private ?SessionInterface $session; - public function __construct(SessionInterface $session = null) + public function __construct(?SessionInterface $session = null) { $this->session = $session; } diff --git a/src/Initializer/InitializerManager.php b/src/Initializer/InitializerManager.php index 6561d87b..558248a2 100644 --- a/src/Initializer/InitializerManager.php +++ b/src/Initializer/InitializerManager.php @@ -29,7 +29,7 @@ public function __construct(ManagerRegistryInterface $registry) $this->registry = $registry; } - public function setLoggingClosure(\Closure $closure = null): void + public function setLoggingClosure(?\Closure $closure = null): void { $this->loggingClosure = $closure; } @@ -52,7 +52,7 @@ public function addInitializer(InitializerInterface $initializer, int $priority /** * Iterate over the registered initializers and execute each of them. */ - public function initialize(string $sessionName = null): void + public function initialize(?string $sessionName = null): void { $loggingClosure = $this->loggingClosure; diff --git a/src/ManagerRegistry.php b/src/ManagerRegistry.php index 17d51607..c9073dd3 100644 --- a/src/ManagerRegistry.php +++ b/src/ManagerRegistry.php @@ -3,10 +3,9 @@ namespace Doctrine\Bundle\PHPCRBundle; use Doctrine\ODM\PHPCR\DocumentManagerInterface; -use Doctrine\ODM\PHPCR\PHPCRException; use PHPCR\SessionInterface; -use Psr\Container\ContainerInterface; use Symfony\Bridge\Doctrine\ManagerRegistry as BaseManagerRegistry; +use Symfony\Component\DependencyInjection\Container; /** * Symfony aware manager registry. @@ -18,7 +17,7 @@ final class ManagerRegistry extends BaseManagerRegistry implements ManagerRegist * @param string[] $entityManagers */ public function __construct( - ContainerInterface $container, + Container $container, array $connections, array $entityManagers, string $defaultConnectionName, diff --git a/src/OptionalCommand/Jackalope/JackrabbitCommand.php b/src/OptionalCommand/Jackalope/JackrabbitCommand.php index cd6a2294..12b910fd 100644 --- a/src/OptionalCommand/Jackalope/JackrabbitCommand.php +++ b/src/OptionalCommand/Jackalope/JackrabbitCommand.php @@ -21,6 +21,7 @@ public function __construct( ) { parent::__construct(self::NAME); } + protected function configure(): void { parent::configure(); diff --git a/src/OptionalCommand/ODM/LoadFixtureCommand.php b/src/OptionalCommand/ODM/LoadFixtureCommand.php index ae4e84d0..b4248a95 100644 --- a/src/OptionalCommand/ODM/LoadFixtureCommand.php +++ b/src/OptionalCommand/ODM/LoadFixtureCommand.php @@ -8,7 +8,6 @@ use Doctrine\Common\DataFixtures\Loader; use Doctrine\Common\DataFixtures\Purger\PHPCRPurger; use Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper; -use InvalidArgumentException; use PHPCR\Util\Console\Command\BaseCommand; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\InputInterface; @@ -117,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $fixtures = $loader->getFixtures(); if (!$fixtures) { - throw new InvalidArgumentException( + throw new \InvalidArgumentException( sprintf('Could not find any fixtures to load in: %s', "\n\n- ".implode("\n- ", $paths)) ); } diff --git a/src/Test/RepositoryManager.php b/src/Test/RepositoryManager.php index da3fd4e5..53de5a80 100644 --- a/src/Test/RepositoryManager.php +++ b/src/Test/RepositoryManager.php @@ -29,7 +29,7 @@ public function getRegistry(): ManagerRegistryInterface return $this->managerRegistry; } - public function getDocumentManager(string $managerName = null): DocumentManagerInterface + public function getDocumentManager(?string $managerName = null): DocumentManagerInterface { return $this->getRegistry()->getManager($managerName); } diff --git a/src/Validator/Constraints/ValidPhpcrOdmValidator.php b/src/Validator/Constraints/ValidPhpcrOdmValidator.php index 7d1efb54..c9af776b 100644 --- a/src/Validator/Constraints/ValidPhpcrOdmValidator.php +++ b/src/Validator/Constraints/ValidPhpcrOdmValidator.php @@ -27,6 +27,9 @@ public function __construct(ManagerRegistryInterface $registry) */ public function validate($document, Constraint $constraint): void { + if (!$constraint instanceof ValidPhpcrOdm) { + throw new \InvalidArgumentException('Expected a constraint of class '.ValidPhpcrOdm::class); + } $className = \get_class($document); $dm = $this->registry->getManagerForClass($className); diff --git a/tests/Fixtures/App/DataFixtures/PHPCR/LoadData.php b/tests/Fixtures/App/DataFixtures/PHPCR/LoadData.php index 6d30d9dd..dae23916 100644 --- a/tests/Fixtures/App/DataFixtures/PHPCR/LoadData.php +++ b/tests/Fixtures/App/DataFixtures/PHPCR/LoadData.php @@ -15,13 +15,16 @@ use Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Document\TestDocument; use Doctrine\Common\DataFixtures\FixtureInterface; use Doctrine\ODM\PHPCR\Document\Generic; -use Doctrine\ODM\PHPCR\DocumentManager; +use Doctrine\ODM\PHPCR\DocumentManagerInterface; use Doctrine\Persistence\ObjectManager; class LoadData implements FixtureInterface { public function load(ObjectManager $manager): void { + if (!$manager instanceof DocumentManagerInterface) { + throw new \InvalidArgumentException('Expected a '.DocumentManagerInterface::class); + } $base = new Generic(); $base->setNodename('test'); $base->setParentDocument($manager->find(null, '/')); diff --git a/tests/Fixtures/App/Document/ReferrerDocument.php b/tests/Fixtures/App/Document/ReferrerDocument.php index 9094802d..83cfc270 100644 --- a/tests/Fixtures/App/Document/ReferrerDocument.php +++ b/tests/Fixtures/App/Document/ReferrerDocument.php @@ -44,17 +44,11 @@ public function addDocument($doc): void $this->documents->add($doc); } - /** - * @return mixed - */ public function getSingle() { return $this->single; } - /** - * @return mixed - */ public function getTestDocument() { return $this->testDocument; @@ -68,9 +62,6 @@ public function getTestDocuments(): Collection return $this->testDocuments; } - /** - * @return mixed - */ public function getDocuments() { return $this->documents; diff --git a/tests/Fixtures/App/config/bundles.php b/tests/Fixtures/App/config/bundles.php index cc92f003..b870b1d2 100644 --- a/tests/Fixtures/App/config/bundles.php +++ b/tests/Fixtures/App/config/bundles.php @@ -1,10 +1,10 @@ ['all' => true], - \Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle::class => ['all' => true], - \Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], - \Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], - \Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], - \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['all' => true], + Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle::class => ['all' => true], + Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], + Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], + Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], + Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['all' => true], ]; diff --git a/tests/Functional/Command/NodeDumpCommandTest.php b/tests/Functional/Command/NodeDumpCommandTest.php index 9787c2c9..7f9ccec8 100644 --- a/tests/Functional/Command/NodeDumpCommandTest.php +++ b/tests/Functional/Command/NodeDumpCommandTest.php @@ -27,7 +27,7 @@ public function testMaxLineLengthOptionIsAppliedSuccessfully(): void 'command' => $command->getName(), '--props' => true, '--max_line_length' => 120, - 'identifier' => '/test/doc-very-long', + 'identifier' => '/test/doc-very-long', ]); $output = $commandTester->getDisplay(); diff --git a/tests/Functional/Form/ChoiceList/PhpcrOdmQueryBuilderLoaderTest.php b/tests/Functional/Form/ChoiceList/PhpcrOdmQueryBuilderLoaderTest.php index 690c50a9..4137dd9e 100644 --- a/tests/Functional/Form/ChoiceList/PhpcrOdmQueryBuilderLoaderTest.php +++ b/tests/Functional/Form/ChoiceList/PhpcrOdmQueryBuilderLoaderTest.php @@ -7,6 +7,7 @@ use Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Document\TestDocument; use Doctrine\Bundle\PHPCRBundle\Tests\Functional\BaseTestCase; use Doctrine\ODM\PHPCR\DocumentManagerInterface; +use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; class PhpcrOdmQueryBuilderLoaderTest extends BaseTestCase { @@ -46,6 +47,7 @@ public function testGetByIdsNotFound(): void public function testGetByIdsFilter(): void { $qb = $this->dm->getRepository(TestDocument::class)->createQueryBuilder('e'); + $this->assertInstanceOf(QueryBuilder::class, $qb); $qb->where()->eq()->field('e.text')->literal('thiswillnotmatch'); $loader = new PhpcrOdmQueryBuilderLoader($qb, $this->dm); $documents = $loader->getEntitiesByIds('id', ['/test/doc']); diff --git a/tests/Functional/Form/Type/DocumentTypeTest.php b/tests/Functional/Form/Type/DocumentTypeTest.php index 916d70ea..f4ee04aa 100644 --- a/tests/Functional/Form/Type/DocumentTypeTest.php +++ b/tests/Functional/Form/Type/DocumentTypeTest.php @@ -8,6 +8,7 @@ use Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Document\TestDocument; use Doctrine\Bundle\PHPCRBundle\Tests\Functional\BaseTestCase; use Doctrine\ODM\PHPCR\DocumentManagerInterface; +use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\FormBuilderInterface; use Twig\Environment; @@ -68,6 +69,7 @@ public function testFiltered(): void ->getRepository(TestDocument::class) ->createQueryBuilder('e') ; + $this->assertInstanceOf(QueryBuilder::class, $qb); $qb->where()->eq()->field('e.text')->literal('thiswillnotmatch'); $formBuilder = $this->createFormBuilder($this->referrer); diff --git a/tests/Unit/Form/DataTransformer/DocumentToPathTransformerTest.php b/tests/Unit/Form/DataTransformer/DocumentToPathTransformerTest.php index 97b16eb8..81f000c1 100644 --- a/tests/Unit/Form/DataTransformer/DocumentToPathTransformerTest.php +++ b/tests/Unit/Form/DataTransformer/DocumentToPathTransformerTest.php @@ -10,7 +10,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\TransformationFailedException; -class DocumentToPathTransformerTest extends Testcase +class DocumentToPathTransformerTest extends TestCase { /** * @var DocumentManager&MockObject diff --git a/tests/Unit/Form/DataTransformer/PHPCRNodeToPathTransformerTest.php b/tests/Unit/Form/DataTransformer/PHPCRNodeToPathTransformerTest.php index dbe31ceb..eb5974fd 100644 --- a/tests/Unit/Form/DataTransformer/PHPCRNodeToPathTransformerTest.php +++ b/tests/Unit/Form/DataTransformer/PHPCRNodeToPathTransformerTest.php @@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Form\Exception\UnexpectedTypeException; -class PHPCRNodeToPathTransformerTest extends Testcase +class PHPCRNodeToPathTransformerTest extends TestCase { /** * @var SessionInterface&MockObject diff --git a/tests/Unit/Form/DataTransformer/PHPCRNodeToUuidTransformerTest.php b/tests/Unit/Form/DataTransformer/PHPCRNodeToUuidTransformerTest.php index 8af5acda..9a653241 100644 --- a/tests/Unit/Form/DataTransformer/PHPCRNodeToUuidTransformerTest.php +++ b/tests/Unit/Form/DataTransformer/PHPCRNodeToUuidTransformerTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class PHPCRNodeToUuidTransformerTest extends Testcase +class PHPCRNodeToUuidTransformerTest extends TestCase { /** * @var SessionInterface&MockObject diff --git a/tests/Unit/Form/Type/PHPCRReferenceTypeTest.php b/tests/Unit/Form/Type/PHPCRReferenceTypeTest.php index 49189aa5..29e31d88 100644 --- a/tests/Unit/Form/Type/PHPCRReferenceTypeTest.php +++ b/tests/Unit/Form/Type/PHPCRReferenceTypeTest.php @@ -11,7 +11,7 @@ use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Form\FormBuilder; -class PHPCRReferenceTypeTest extends Testcase +class PHPCRReferenceTypeTest extends TestCase { /** * @var FormBuilder&MockObject diff --git a/tests/Unit/Form/Type/PathTypeTest.php b/tests/Unit/Form/Type/PathTypeTest.php index 2aa4a14b..7d39286a 100644 --- a/tests/Unit/Form/Type/PathTypeTest.php +++ b/tests/Unit/Form/Type/PathTypeTest.php @@ -11,7 +11,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Form\FormBuilder; -class PathTypeTest extends Testcase +class PathTypeTest extends TestCase { /** * @var ManagerRegistryInterface&MockObject diff --git a/tests/Unit/Initializer/GenericInitializerTest.php b/tests/Unit/Initializer/GenericInitializerTest.php index a972a7a1..4f525186 100644 --- a/tests/Unit/Initializer/GenericInitializerTest.php +++ b/tests/Unit/Initializer/GenericInitializerTest.php @@ -13,7 +13,10 @@ class GenericInitializerTest extends TestCase { - protected ManagerRegistryInterface $registry; + /** + * @var ManagerRegistryInterface&MockObject + */ + private ManagerRegistryInterface $registry; /** * @var SessionInterface&MockObject */