diff --git a/.gitattributes b/.gitattributes index 061a655e..5fef55da 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,6 +5,4 @@ /phpcs.xml.dist export-ignore /phpstan.neon export-ignore /phpunit.xml.dist export-ignore -/psalm.xml.dist export-ignore -/psalm-baseline.xml export-ignore /tests/ export-ignore diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 064cba96..1e78392d 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -4,13 +4,25 @@ on: pull_request: branches: - "*.x" + paths: + - ".github/workflows/coding-standards.yml" + - "composer.*" + - "src/**" + - "phpcs.xml.dist" + - "tests/**" push: branches: - "*.x" + paths: + - ".github/workflows/coding-standards.yml" + - "composer.*" + - "src/**" + - "phpcs.xml.dist" + - "tests/**" jobs: coding-standards: name: "Coding Standards" - uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.5.1" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@6.0.0" with: - php-version: '8.3' + php-version: "8.3" diff --git a/.github/workflows/composer-lint.yml b/.github/workflows/composer-lint.yml new file mode 100644 index 00000000..39e14e0c --- /dev/null +++ b/.github/workflows/composer-lint.yml @@ -0,0 +1,22 @@ +name: "Composer Lint" + +on: + pull_request: + branches: + - "*.x" + paths: + - ".github/workflows/composer-lint.yml" + - "composer.json" + push: + branches: + - "*.x" + paths: + - ".github/workflows/composer-lint.yml" + - "composer.json" + +jobs: + composer-lint: + name: "Composer Lint" + uses: "doctrine/.github/.github/workflows/composer-lint.yml@6.0.0" + with: + php-version: "8.3" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ef0d9622..ce162874 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -4,9 +4,21 @@ on: pull_request: branches: - "*.x" + paths: + - ".github/workflows/continuous-integration.yml" + - "composer.*" + - "src/**" + - "phpunit.xml.dist" + - "tests/**" push: branches: - "*.x" + paths: + - ".github/workflows/continuous-integration.yml" + - "composer.*" + - "src/**" + - "phpunit.xml.dist" + - "tests/**" jobs: phpunit: @@ -17,12 +29,10 @@ jobs: fail-fast: false matrix: php-version: - - "8.0" - "8.1" - "8.2" - "8.3" dbal-version: - - "2.13.0" - "3.3.0" dependencies: - "highest" @@ -30,19 +40,11 @@ jobs: - true - false include: - - php-version: "8.0" - dbal-version: "2.13.0" - dependencies: "lowest" - optional-dependencies: false - - php-version: "8.0" + - php-version: "8.1" dbal-version: "3.3.0" dependencies: "lowest" optional-dependencies: false - - php-version: "8.0" - dbal-version: "2.13.0" - dependencies: "lowest" - optional-dependencies: true - - php-version: "8.0" + - php-version: "8.1" dbal-version: "3.3.0" dependencies: "lowest" optional-dependencies: true @@ -61,26 +63,31 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" with: fetch-depth: 2 - - name: "Install PHP" + - name: "Install PHP with PCOV" uses: "shivammathur/setup-php@v2" with: php-version: "${{ matrix.php-version }}" coverage: "pcov" - ini-values: "error_reporting=E_ALL, zend.assertions=1" + ini-values: "zend.assertions=1" extensions: "pdo_mysql" + - name: "Set COMPOSER_ROOT_VERSION" + run: | + echo "COMPOSER_ROOT_VERSION=${{ inputs.composer-root-version }}" >> $GITHUB_ENV + if: "${{ inputs.composer-root-version }}" + - name: "Require specific DBAL version" run: "composer require doctrine/dbal ^${{ matrix.dbal-version }} --no-update" - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v3" with: dependency-versions: "${{ matrix.dependencies }}" - composer-options: "--prefer-dist --no-suggest" + composer-options: "${{ inputs.composer-options }}" - name: "Remove optional dependencies" if: "! matrix.optional-dependencies" @@ -103,29 +110,31 @@ jobs: run: "./ci/run-cli-migrations.sh" - name: "Upload coverage file" - uses: "actions/upload-artifact@v2" + uses: "actions/upload-artifact@v4" with: - name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ matrix.dbal-version }}.coverage" + name: "phpunit-${{ matrix.php-version }}-${{ matrix.dependencies }}-${{ matrix.optional-dependencies }}-${{ matrix.dbal-version }}.coverage" path: "coverage.xml" upload_coverage: name: "Upload coverage to Codecov" - runs-on: "ubuntu-20.04" + runs-on: "ubuntu-22.04" needs: - "phpunit" steps: - name: "Checkout" - uses: "actions/checkout@v2" + uses: "actions/checkout@v4" with: fetch-depth: 2 - name: "Download coverage files" - uses: "actions/download-artifact@v2" + uses: "actions/download-artifact@v4" with: path: "reports" - name: "Upload to Codecov" - uses: "codecov/codecov-action@v1" + uses: "codecov/codecov-action@v5" with: directory: "reports" + env: + CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 00000000..84bf616c --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,20 @@ +name: "Documentation" + +on: + pull_request: + branches: + - "*.x" + paths: + - ".github/workflows/documentation.yml" + - "docs/**" + push: + branches: + - "*.x" + paths: + - ".github/workflows/documentation.yml" + - "docs/**" + +jobs: + documentation: + name: "Documentation" + uses: "doctrine/.github/.github/workflows/documentation.yml@6.0.0" diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 00000000..f1e6edc2 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,28 @@ +name: "Static Analysis" + +on: + pull_request: + branches: + - "*.x" + paths: + - ".github/workflows/phpstan.yml" + - "composer.*" + - "src/**" + - "phpstan*" + - "tests/**" + push: + branches: + - "*.x" + paths: + - ".github/workflows/phpstan.yml" + - "composer.*" + - "src/**" + - "phpstan*" + - "tests/**" + +jobs: + static-analysis: + name: "Static Analysis" + uses: "doctrine/.github/.github/workflows/phpstan.yml@6.0.0" + with: + php-version: "8.3" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index 0f4c96ee..6f621466 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -8,11 +8,11 @@ on: jobs: release: name: "Git tag, release & create merge-up PR" - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.5.1" - with: - use-next-minor-as-default-branch: true + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@6.0.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }} SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }} + with: + use-next-minor-as-default-branch: true # defaults to false diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml deleted file mode 100644 index 3a51c02e..00000000 --- a/.github/workflows/static-analysis.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: "Static Analysis" - -on: - pull_request: - branches: - - "*.x" - push: - branches: - - "*.x" - -jobs: - static-analysis: - name: "Static Analysis" - uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.5.1" - with: - php-version: '8.3' diff --git a/.gitignore b/.gitignore index 7dca275e..4142c48d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /.phpcs.cache -/.phpunit.result.cache +/.phpunit.cache/ /ci/20*/ /config/application.config.php /coverage.xml diff --git a/composer.json b/composer.json index 5c873cd0..2a14aec5 100644 --- a/composer.json +++ b/composer.json @@ -1,96 +1,56 @@ { "name": "doctrine/doctrine-orm-module", "description": "Laminas Module that provides Doctrine ORM functionality", - "type": "library", "license": "MIT", + "type": "library", "keywords": [ "doctrine", "orm", "module", "laminas" ], - "homepage": "http://www.doctrine-project.org/", - "authors": [ - { - "name": "Kyle Spraggs", - "email": "theman@spiffyjr.me", - "homepage": "http://www.spiffyjr.me/" - }, - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://marco-pivetta.com/" - }, - { - "name": "Evan Coury", - "email": "me@evancoury.com", - "homepage": "http://blog.evan.pro/" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@hotmail.com" - }, - { - "name": "Tom H Anderson", - "email": "tom.h.anderson@gmail.com" - } - ], - "config": { - "sort-packages": true, - "allow-plugins": { - "composer/package-versions-deprecated": true, - "dealerdirect/phpcodesniffer-composer-installer": true - } - }, - "extra": { - "laminas": { - "config-provider": "DoctrineORMModule\\ConfigProvider", - "module": "DoctrineORMModule" - } - }, + "homepage": "https://www.doctrine-project.org/", "require": { - "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0", "ext-json": "*", - "doctrine/dbal": "^2.13.7 || ^3.3.2", - "doctrine/doctrine-laminas-hydrator": "^3.0.0", - "doctrine/doctrine-module": "^5.3.0 || ^6.0.2", - "doctrine/event-manager": "^1.1.1", - "doctrine/orm": "^2.11.1", - "doctrine/persistence": "^2.3.0 || ^3.0.0", - "laminas/laminas-eventmanager": "^3.4.0", + "doctrine/dbal": "^3.3.2", + "doctrine/doctrine-laminas-hydrator": "^3.2.0", + "doctrine/doctrine-module": "^6.2.0", + "doctrine/event-manager": "^2.0.0", + "doctrine/orm": "^2.13.0", + "doctrine/persistence": "^3.0.0", + "laminas/laminas-eventmanager": "^3.5.0", "laminas/laminas-modulemanager": "^2.11.0", - "laminas/laminas-mvc": "^3.3.2", - "laminas/laminas-paginator": "^2.12.2", + "laminas/laminas-mvc": "^3.3.5", + "laminas/laminas-paginator": "^2.13.0", "laminas/laminas-servicemanager": "^3.17.0", - "laminas/laminas-stdlib": "^3.7.1", + "laminas/laminas-stdlib": "^3.13.0", "psr/container": "^1.1.2", - "symfony/console": "^5.4.3 || ^6.0.3" + "symfony/console": "^6.1.2 || ^7.0.0" }, "require-dev": { - "doctrine/annotations": "^1.13.2", - "doctrine/coding-standard": "^9.0.0", - "doctrine/data-fixtures": "^1.5.2", - "doctrine/migrations": "^3.4.1", + "doctrine/annotations": "^2.0.0", + "doctrine/coding-standard": "^12.0.0", + "doctrine/data-fixtures": "^2.0.1", + "doctrine/migrations": "^3.8.0", "laminas/laminas-cache-storage-adapter-filesystem": "^2.0", "laminas/laminas-cache-storage-adapter-memory": "^2.0", "laminas/laminas-developer-tools": "^2.3.0", - "laminas/laminas-i18n": "^2.13.0", - "laminas/laminas-log": "^2.15.0", + "laminas/laminas-i18n": "^2.23.0", "laminas/laminas-serializer": "^2.12.0", - "ocramius/proxy-manager": "^2.2.0", - "phpstan/phpstan": "^1.4.6", - "phpstan/phpstan-phpunit": "^1.0.0", - "phpunit/phpunit": "^9.5.13", - "squizlabs/php_codesniffer": "^3.6.2", - "vimeo/psalm": "^5.4.0" + "phpstan/phpstan": "^2.0.4", + "phpstan/phpstan-phpunit": "^2.0.3", + "phpunit/phpunit": "^10.5.40" }, "conflict": { - "doctrine/migrations": "<3.3" + "doctrine/data-fixtures": "<2.0", + "doctrine/migrations": "<3.8", + "laminas/laminas-form": "<3.10" }, "suggest": { - "laminas/laminas-form": "if you want to use form elements backed by Doctrine", + "doctrine/migrations": "doctrine migrations if you want to keep your schema definitions versioned", "laminas/laminas-developer-tools": "laminas-developer-tools if you want to profile operations executed by the ORM during development", - "doctrine/migrations": "doctrine migrations if you want to keep your schema definitions versioned" + "laminas/laminas-form": "if you want to use form elements backed by Doctrine" }, "autoload": { "psr-4": { @@ -102,17 +62,28 @@ "DoctrineORMModuleTest\\": "tests/" } }, + "config": { + "allow-plugins": { + "composer/package-versions-deprecated": true, + "dealerdirect/phpcodesniffer-composer-installer": true + }, + "sort-packages": true + }, + "extra": { + "laminas": { + "config-provider": "DoctrineORMModule\\ConfigProvider", + "module": "DoctrineORMModule" + } + }, "scripts": { "check": [ "@cs-check", "@phpstan", - "@psalm", "@test" ], "cs-check": "phpcs", "cs-fix": "phpcbf", "phpstan": "phpstan analyse", - "psalm": "psalm --stats", "test": "phpunit --colors=always", "test-coverage": "phpunit --colors=always --coverage-clover=coverage.xml" } diff --git a/docs/en/index.rst b/docs/en/index.rst index 3f937dc0..2c7663af 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -23,13 +23,17 @@ Run the following to install this library using `Composer `: + general introduction. +- :doc:`Developer Tools `: + setting up Laminas Developer Tools. +- :doc:`Configuration `: + learn how to configure DoctrineORMModule. +- :doc:`Caching `: + learn how to configure caches. +- :doc:`Migrations `: + learn how to use database migrations. +- :doc:`Laminas Forms `: + learn about custom Laminas form elements. +- :doc:`Laminas Forms `: + learn about authentication and custom DBAL types. diff --git a/docs/en/sidebar.rst b/docs/en/sidebar.rst index a5ba7b1b..48f9a500 100644 --- a/docs/en/sidebar.rst +++ b/docs/en/sidebar.rst @@ -1,11 +1,14 @@ +:orphan: + .. toctree:: - :depth: 3 + :caption: Doctrine ORM Module + :depth: 3 - index - user-guide - developer-tools - configuration - cache - migrations - forms - miscellaneous + index + user-guide + developer-tools + configuration + cache + migrations + forms + miscellaneous diff --git a/phpcs.xml b/phpcs.xml.dist similarity index 84% rename from phpcs.xml rename to phpcs.xml.dist index c9a242d5..76202979 100644 --- a/phpcs.xml +++ b/phpcs.xml.dist @@ -6,8 +6,8 @@ - - + + diff --git a/phpstan.neon b/phpstan.neon index ded2cec1..677e2018 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,17 +3,25 @@ parameters: paths: - src - tests - checkGenericClassInNonGenericObjectType: false treatPhpDocTypesAsCertain: false ignoreErrors: - - message: '#Offset mixed on array\{\} in isset\(\) does not exist#' - path: src/Yuml/MetadataGrapher.php + identifier: missingType.generics - - message: '#Return type .* of method DoctrineORMModule\\Yuml\\YumlController::indexAction\(\)#' - path: src/Yuml/YumlController.php + identifier: method.alreadyNarrowedType - - message: '#Parameter \#1 .* of method DoctrineORMModule\\Options\\Configuration.* stdClass given#' - path: tests/Options/ConfigurationOptionsTest.php + identifier: function.alreadyNarrowedType + - + message: '#Method .*DBALConnection::getDriverClass\(\) never returns null#' + path: src/Options/DBALConnection.php + - + message: '#Offset mixed on array\{\} in isset\(\) does not exist#' + path: src/Yuml/MetadataGrapher.php + - + message: '#Return type .* of method DoctrineORMModule\\Yuml\\YumlController::indexAction\(\)#' + path: src/Yuml/YumlController.php + - + message: '#Parameter \#1 .* of method DoctrineORMModule\\Options\\Configuration.* stdClass given#' + path: tests/Options/ConfigurationOptionsTest.php includes: - vendor/phpstan/phpstan-phpunit/extension.neon diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f2bc8b3d..8f56fffa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,24 +1,17 @@ - - - + + + + + ./tests + + + ./src - - - ./tests - + diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index 6a931ebb..00000000 --- a/psalm.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - diff --git a/src/CliConfigurator.php b/src/CliConfigurator.php index b997d1dc..6d480a8b 100644 --- a/src/CliConfigurator.php +++ b/src/CliConfigurator.php @@ -4,8 +4,6 @@ namespace DoctrineORMModule; -use Doctrine\DBAL\Tools\Console\Command\ImportCommand; -use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; use Doctrine\Migrations\Tools\Console\Command\VersionCommand; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; @@ -61,17 +59,8 @@ class CliConfigurator 'doctrine.migrations_cmd.uptodate', ]; - private ContainerInterface $container; - - public function __construct(ContainerInterface $container) + public function __construct(private ContainerInterface $container) { - $this->container = $container; - - if (! class_exists(ImportCommand::class)) { - return; - } - - $this->commands[] = 'doctrine.dbal_cmd.import'; } public function configure(Application $cli): void @@ -92,22 +81,13 @@ public function configure(Application $cli): void } } - /** - * @return array - */ + /** @return array */ private function getHelpers(EntityManagerInterface $objectManager): array { - $helpers = [ + return [ 'dialog' => new QuestionHelper(), 'em' => new EntityManagerHelper($objectManager), ]; - - // this is only available with DBAL 2.x - if (class_exists(ConnectionHelper::class)) { - $helpers['db'] = new ConnectionHelper($objectManager->getConnection()); - } - - return $helpers; } private function createObjectManagerInputOption(): InputOption @@ -117,7 +97,7 @@ private function createObjectManagerInputOption(): InputOption null, InputOption::VALUE_OPTIONAL, 'The name of the object manager to use.', - $this->defaultObjectManagerName + $this->defaultObjectManagerName, ); } @@ -129,13 +109,10 @@ private function getObjectManagerName(): string return $this->defaultObjectManagerName; } - /** @psalm-suppress ReservedWord */ return $arguments->getParameterOption('--object-manager'); } - /** - * @return string[] - */ + /** @return string[] */ private function getAvailableCommands(): array { if (class_exists(VersionCommand::class)) { diff --git a/src/Collector/MappingCollector.php b/src/Collector/MappingCollector.php index 4a303611..ef93c2ed 100644 --- a/src/Collector/MappingCollector.php +++ b/src/Collector/MappingCollector.php @@ -22,17 +22,14 @@ class MappingCollector implements CollectorInterface, AutoHideInterface */ public const PRIORITY = 10; - protected string $name; - - protected ?ClassMetadataFactory $classMetadataFactory = null; + protected ClassMetadataFactory|null $classMetadataFactory = null; /** @var ClassMetadata[] indexed by class name */ protected array $classes = []; - public function __construct(ClassMetadataFactory $classMetadataFactory, string $name) + public function __construct(ClassMetadataFactory $classMetadataFactory, protected string $name) { $this->classMetadataFactory = $classMetadataFactory; - $this->name = $name; } public function getName(): string @@ -67,9 +64,7 @@ public function canHide(): bool return empty($this->classes); } - /** - * @return array{name: string, classes: ClassMetadata[]} - */ + /** @return array{name: string, classes: ClassMetadata[]} */ public function __serialize(): array { return [ @@ -78,18 +73,14 @@ public function __serialize(): array ]; } - /** - * @param array{name: string, classes: ClassMetadata[]} $data - */ + /** @param array{name: string, classes: ClassMetadata[]} $data */ public function __unserialize(array $data): void { $this->name = $data['name']; $this->classes = $data['classes']; } - /** - * @return ClassMetadata[] - */ + /** @return ClassMetadata[] */ public function getClasses(): array { return $this->classes; diff --git a/src/Collector/SQLLoggerCollector.php b/src/Collector/SQLLoggerCollector.php index dd106d8b..94ee6704 100644 --- a/src/Collector/SQLLoggerCollector.php +++ b/src/Collector/SQLLoggerCollector.php @@ -21,14 +21,8 @@ class SQLLoggerCollector implements CollectorInterface, AutoHideInterface */ public const PRIORITY = 10; - protected DebugStack $sqlLogger; - - protected string $name; - - public function __construct(DebugStack $sqlLogger, string $name) + public function __construct(protected DebugStack $sqlLogger, protected string $name) { - $this->sqlLogger = $sqlLogger; - $this->name = $name; } public function getName(): string @@ -55,9 +49,7 @@ public function getQueryCount(): int return count($this->sqlLogger->queries); } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getQueries(): array { return $this->sqlLogger->queries; diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index 16fd7903..8e4b5217 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -9,9 +9,7 @@ */ final class ConfigProvider { - /** - * @return mixed[] - */ + /** @return mixed[] */ public function __invoke(): array { $config = include __DIR__ . '/../config/module.config.php'; diff --git a/src/Form/Annotation/DoctrineAnnotationListener.php b/src/Form/Annotation/DoctrineAnnotationListener.php index b9e32654..fe7d5038 100644 --- a/src/Form/Annotation/DoctrineAnnotationListener.php +++ b/src/Form/Annotation/DoctrineAnnotationListener.php @@ -19,11 +19,8 @@ class DoctrineAnnotationListener extends AbstractListenerAggregate { - protected ObjectManager $objectManager; - - public function __construct(ObjectManager $objectManager) + public function __construct(protected ObjectManager $objectManager) { - $this->objectManager = $objectManager; } /** @@ -33,45 +30,43 @@ public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_CONFIGURE_FIELD, - [$this, 'handleFilterField'] + [$this, 'handleFilterField'], ); $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_CONFIGURE_FIELD, - [$this, 'handleTypeField'] + [$this, 'handleTypeField'], ); $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_CONFIGURE_FIELD, - [$this, 'handleValidatorField'] + [$this, 'handleValidatorField'], ); $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_CONFIGURE_FIELD, - [$this, 'handleRequiredField'] + [$this, 'handleRequiredField'], ); $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_EXCLUDE_FIELD, - [$this, 'handleExcludeField'] + [$this, 'handleExcludeField'], ); $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_CONFIGURE_ASSOCIATION, - [$this, 'handleToOne'] + [$this, 'handleToOne'], ); $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_CONFIGURE_ASSOCIATION, - [$this, 'handleToMany'] + [$this, 'handleToMany'], ); $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_CONFIGURE_ASSOCIATION, - [$this, 'handleRequiredAssociation'] + [$this, 'handleRequiredAssociation'], ); $this->listeners[] = $events->attach( EntityBasedFormBuilder::EVENT_EXCLUDE_ASSOCIATION, - [$this, 'handleExcludeAssociation'] + [$this, 'handleExcludeAssociation'], ); } - /** - * @internal - */ + /** @internal */ public function handleToOne(EventInterface $event): void { $metadata = $event->getParam('metadata'); @@ -84,9 +79,7 @@ public function handleToOne(EventInterface $event): void $this->mergeAssociationOptions($event->getParam('elementSpec'), $mapping['targetEntity']); } - /** - * @internal - */ + /** @internal */ public function handleToMany(EventInterface $event): void { $metadata = $event->getParam('metadata'); @@ -106,9 +99,7 @@ public function handleToMany(EventInterface $event): void $elementSpec['spec']['attributes']['multiple'] = true; } - /** - * @internal - */ + /** @internal */ public function handleExcludeAssociation(EventInterface $event): bool { $metadata = $event->getParam('metadata'); @@ -116,9 +107,7 @@ public function handleExcludeAssociation(EventInterface $event): bool return $metadata && $metadata->isAssociationInverseSide($event->getParam('name')); } - /** - * @internal - */ + /** @internal */ public function handleExcludeField(EventInterface $event): bool { $metadata = $event->getParam('metadata'); @@ -128,9 +117,7 @@ public function handleExcludeField(EventInterface $event): bool $metadata->generatorType === ClassMetadata::GENERATOR_TYPE_IDENTITY; } - /** - * @internal - */ + /** @internal */ public function handleFilterField(EventInterface $event): void { $metadata = $event->getParam('metadata'); @@ -165,9 +152,7 @@ public function handleFilterField(EventInterface $event): void } } - /** - * @internal - */ + /** @internal */ public function handleRequiredAssociation(EventInterface $event): void { $metadata = $event->getParam('metadata'); @@ -206,9 +191,7 @@ public function handleRequiredAssociation(EventInterface $event): void } } - /** - * @internal - */ + /** @internal */ public function handleRequiredField(EventInterface $event): void { $this->prepareEvent($event); @@ -223,9 +206,7 @@ public function handleRequiredField(EventInterface $event): void $inputSpec['required'] = ! $metadata->isNullable($event->getParam('name')); } - /** - * @internal - */ + /** @internal */ public function handleTypeField(EventInterface $event): void { $metadata = $event->getParam('metadata'); @@ -281,9 +262,7 @@ public function handleTypeField(EventInterface $event): void $elementSpec['spec']['type'] = $type; } - /** - * @internal - */ + /** @internal */ public function handleValidatorField(EventInterface $event): void { $mapping = $this->getFieldMapping($event); @@ -333,10 +312,8 @@ public function handleValidatorField(EventInterface $event): void } } - /** - * @return mixed[]|null - */ - protected function getFieldMapping(EventInterface $event): ?array + /** @return mixed[]|null */ + protected function getFieldMapping(EventInterface $event): array|null { $metadata = $event->getParam('metadata'); if ($metadata && $metadata->hasField($event->getParam('name'))) { @@ -346,10 +323,8 @@ protected function getFieldMapping(EventInterface $event): ?array return null; } - /** - * @return mixed[]|null - */ - protected function getAssociationMapping(EventInterface $event): ?array + /** @return mixed[]|null */ + protected function getAssociationMapping(EventInterface $event): array|null { $metadata = $event->getParam('metadata'); if ($metadata && $metadata->hasAssociation($event->getParam('name'))) { @@ -367,7 +342,7 @@ protected function mergeAssociationOptions(ArrayObject $elementSpec, string $tar 'object_manager' => $this->objectManager, 'target_class' => $targetEntity, ], - $options + $options, ); $elementSpec['spec']['options'] = $options; diff --git a/src/Form/Annotation/EntityBasedFormBuilder.php b/src/Form/Annotation/EntityBasedFormBuilder.php index 3554f33f..3c408624 100644 --- a/src/Form/Annotation/EntityBasedFormBuilder.php +++ b/src/Form/Annotation/EntityBasedFormBuilder.php @@ -34,28 +34,23 @@ final class EntityBasedFormBuilder protected AbstractBuilder $builder; - protected ObjectManager $objectManager; - /** * Constructor. Ensures ObjectManager is present. */ - public function __construct(ObjectManager $objectManager, ?AbstractBuilder $builder = null) + public function __construct(protected ObjectManager $objectManager, AbstractBuilder|null $builder = null) { if (! class_exists(AbstractBuilder::class)) { throw new RuntimeException(sprintf( 'Usage of %s requires laminas-form 3.0.0 or newer, which currently is not installed.', - self::class + self::class, )); } - $this->objectManager = $objectManager; - $this->builder = $builder ?? new LaminasAnnotationBuilder(); + $this->builder = $builder ?? new LaminasAnnotationBuilder(); (new DoctrineAnnotationListener($this->objectManager))->attach($this->builder->getEventManager()); } - /** - * @return AbstractBuilder the form builder from laminas-form - */ + /** @return AbstractBuilder the form builder from laminas-form */ public function getBuilder(): AbstractBuilder { return $this->builder; diff --git a/src/Module.php b/src/Module.php index 1da56e33..0b3ccb0c 100644 --- a/src/Module.php +++ b/src/Module.php @@ -38,7 +38,7 @@ static function (EventInterface $event): void { ->get(CliConfigurator::class) ->configure($event->getTarget()); }, - 1 + 1, ); // Initialize logger collector in DeveloperTools @@ -54,7 +54,7 @@ static function (EventInterface $event): void { static function ($event): void { $container = $event->getTarget()->getParam('ServiceManager'); $container->get('doctrine.sql_logger_collector.orm_default'); - } + }, ); } diff --git a/src/Options/Configuration.php b/src/Options/Configuration.php index bcee2767..08e178e9 100644 --- a/src/Options/Configuration.php +++ b/src/Options/Configuration.php @@ -142,7 +142,7 @@ final class Configuration extends DBALConfiguration /** * Default repository class */ - protected ?string $defaultRepositoryClassName = null; + protected string|null $defaultRepositoryClassName = null; /** * Repository factory or name of the repository factory service to be set in ORM @@ -154,7 +154,7 @@ final class Configuration extends DBALConfiguration * Class name of MetaData factory to be set in ORM. * The entityManager will create a new instance on construction. */ - protected ?string $classMetadataFactoryName = null; + protected string|null $classMetadataFactoryName = null; /** * Entity listener resolver or service name of the entity listener resolver @@ -169,12 +169,12 @@ final class Configuration extends DBALConfiguration * * @link http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/second-level-cache.html */ - protected ?SecondLevelCacheConfiguration $secondLevelCache = null; + protected SecondLevelCacheConfiguration|null $secondLevelCache = null; /** * Configuration option for the filter schema assets expression */ - protected ?string $filterSchemaAssetsExpression = null; + protected string|null $filterSchemaAssetsExpression = null; /** * Stack of middleware names @@ -190,9 +190,7 @@ final class Configuration extends DBALConfiguration */ protected $schemaAssetsFilter = null; - /** - * @param mixed[] $datetimeFunctions - */ + /** @param mixed[] $datetimeFunctions */ public function setDatetimeFunctions(array $datetimeFunctions): self { $this->datetimeFunctions = $datetimeFunctions; @@ -200,9 +198,7 @@ public function setDatetimeFunctions(array $datetimeFunctions): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getDatetimeFunctions(): array { return $this->datetimeFunctions; @@ -220,9 +216,7 @@ public function getDriver(): string return 'doctrine.driver.' . $this->driver; } - /** - * @param mixed[] $entityNamespaces - */ + /** @param mixed[] $entityNamespaces */ public function setEntityNamespaces(array $entityNamespaces): self { $this->entityNamespaces = $entityNamespaces; @@ -230,9 +224,7 @@ public function setEntityNamespaces(array $entityNamespaces): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getEntityNamespaces(): array { return $this->entityNamespaces; @@ -284,9 +276,7 @@ public function getHydrationCache(): string return 'doctrine.cache.' . $this->hydrationCache; } - /** - * @param mixed[] $namedNativeQueries - */ + /** @param mixed[] $namedNativeQueries */ public function setNamedNativeQueries(array $namedNativeQueries): self { $this->namedNativeQueries = $namedNativeQueries; @@ -294,17 +284,13 @@ public function setNamedNativeQueries(array $namedNativeQueries): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getNamedNativeQueries(): array { return $this->namedNativeQueries; } - /** - * @param mixed[] $namedQueries - */ + /** @param mixed[] $namedQueries */ public function setNamedQueries(array $namedQueries): self { $this->namedQueries = $namedQueries; @@ -312,17 +298,13 @@ public function setNamedQueries(array $namedQueries): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getNamedQueries(): array { return $this->namedQueries; } - /** - * @param mixed[] $numericFunctions - */ + /** @param mixed[] $numericFunctions */ public function setNumericFunctions(array $numericFunctions): self { $this->numericFunctions = $numericFunctions; @@ -330,17 +312,13 @@ public function setNumericFunctions(array $numericFunctions): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getNumericFunctions(): array { return $this->numericFunctions; } - /** - * @param mixed[] $filters - */ + /** @param mixed[] $filters */ public function setFilters(array $filters): self { $this->filters = $filters; @@ -348,9 +326,7 @@ public function setFilters(array $filters): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getFilters(): array { return $this->filters; @@ -392,9 +368,7 @@ public function getQueryCache(): string return 'doctrine.cache.' . $this->queryCache; } - /** - * @param mixed[] $stringFunctions - */ + /** @param mixed[] $stringFunctions */ public function setStringFunctions(array $stringFunctions): self { $this->stringFunctions = $stringFunctions; @@ -402,17 +376,13 @@ public function setStringFunctions(array $stringFunctions): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getStringFunctions(): array { return $this->stringFunctions; } - /** - * @param mixed[] $modes - */ + /** @param mixed[] $modes */ public function setCustomHydrationModes(array $modes): self { $this->customHydrationModes = $modes; @@ -420,9 +390,7 @@ public function setCustomHydrationModes(array $modes): self return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getCustomHydrationModes(): array { return $this->customHydrationModes; @@ -476,7 +444,7 @@ public function setClassMetadataFactoryName(string $factoryName): self return $this; } - public function getClassMetadataFactoryName(): ?string + public function getClassMetadataFactoryName(): string|null { return $this->classMetadataFactoryName; } @@ -493,9 +461,7 @@ public function getEntityListenerResolver(): string|EntityListenerResolver|null return $this->entityListenerResolver; } - /** - * @param mixed[] $secondLevelCache - */ + /** @param mixed[] $secondLevelCache */ public function setSecondLevelCache(array $secondLevelCache): self { $this->secondLevelCache = new SecondLevelCacheConfiguration($secondLevelCache); @@ -515,7 +481,7 @@ public function setFilterSchemaAssetsExpression(string $filterSchemaAssetsExpres return $this; } - public function getFilterSchemaAssetsExpression(): ?string + public function getFilterSchemaAssetsExpression(): string|null { return $this->filterSchemaAssetsExpression; } @@ -527,7 +493,7 @@ public function setSchemaAssetsFilter(callable $schemaAssetsFilter): self return $this; } - public function getSchemaAssetsFilter(): ?callable + public function getSchemaAssetsFilter(): callable|null { return $this->schemaAssetsFilter; } @@ -545,22 +511,18 @@ public function setDefaultRepositoryClassName(string $className): self /** * Get default repository class name. */ - public function getDefaultRepositoryClassName(): ?string + public function getDefaultRepositoryClassName(): string|null { return $this->defaultRepositoryClassName; } - /** - * @param array> $middlewares - */ + /** @param array> $middlewares */ public function setMiddlewares(array $middlewares): void { $this->middlewares = $middlewares; } - /** - * @return array> - */ + /** @return array> */ public function getMiddlewares(): array { return $this->middlewares; diff --git a/src/Options/DBALConfiguration.php b/src/Options/DBALConfiguration.php index 91144166..ee298641 100644 --- a/src/Options/DBALConfiguration.php +++ b/src/Options/DBALConfiguration.php @@ -23,7 +23,7 @@ class DBALConfiguration extends AbstractOptions /** * Set the class name of the SQL Logger, or null, to disable. */ - protected ?string $sqlLogger = null; + protected string|null $sqlLogger = null; /** * Keys must be the name of the type identifier and value is @@ -48,14 +48,12 @@ public function setSqlLogger(string $sqlLogger): void $this->sqlLogger = $sqlLogger; } - public function getSqlLogger(): ?string + public function getSqlLogger(): string|null { return $this->sqlLogger; } - /** - * @param mixed[] $types - */ + /** @param mixed[] $types */ public function setTypes(array $types): void { $this->types = $types; diff --git a/src/Options/DBALConnection.php b/src/Options/DBALConnection.php index 19651a34..7cfd52a3 100644 --- a/src/Options/DBALConnection.php +++ b/src/Options/DBALConnection.php @@ -47,7 +47,7 @@ final class DBALConnection extends AbstractOptions * Set the wrapper class for the driver. In general, this should not * need to be changed. */ - protected ?string $wrapperClass = null; + protected string|null $wrapperClass = null; /** * Driver specific connection parameters. @@ -84,25 +84,19 @@ public function getEventmanager(): string return 'doctrine.eventmanager.' . $this->eventmanager; } - /** - * @param mixed[] $params - */ + /** @param mixed[] $params */ public function setParams(array $params): void { $this->params = $params; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getParams(): array { return $this->params; } - /** - * @param mixed[] $doctrineTypeMappings - */ + /** @param mixed[] $doctrineTypeMappings */ public function setDoctrineTypeMappings(array $doctrineTypeMappings): DBALConnection { $this->doctrineTypeMappings = $doctrineTypeMappings; @@ -110,9 +104,7 @@ public function setDoctrineTypeMappings(array $doctrineTypeMappings): DBALConnec return $this; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getDoctrineTypeMappings(): array { return $this->doctrineTypeMappings; @@ -138,15 +130,13 @@ public function getDoctrineCommentedTypes(): array return $this->doctrineCommentedTypes; } - public function setDriverClass(?string $driverClass): void + public function setDriverClass(string|null $driverClass): void { $this->driverClass = $driverClass; } - /** - * @return class-string|null - */ - public function getDriverClass(): ?string + /** @return class-string|null */ + public function getDriverClass(): string|null { return $this->driverClass; } @@ -166,10 +156,8 @@ public function setWrapperClass(string $wrapperClass): void $this->wrapperClass = $wrapperClass; } - /** - * @return class-string|null - */ - public function getWrapperClass(): ?string + /** @return class-string|null */ + public function getWrapperClass(): string|null { return $this->wrapperClass; } diff --git a/src/Options/EntityManager.php b/src/Options/EntityManager.php index 3e37d1d8..e1da0e8a 100644 --- a/src/Options/EntityManager.php +++ b/src/Options/EntityManager.php @@ -6,9 +6,7 @@ use Laminas\Stdlib\AbstractOptions; -/** - * @template-extends AbstractOptions - */ +/** @template-extends AbstractOptions */ final class EntityManager extends AbstractOptions { /** diff --git a/src/Options/EntityResolver.php b/src/Options/EntityResolver.php index 96103077..34e353da 100644 --- a/src/Options/EntityResolver.php +++ b/src/Options/EntityResolver.php @@ -10,9 +10,7 @@ use function class_exists; use function sprintf; -/** - * @template-extends AbstractOptions - */ +/** @template-extends AbstractOptions */ final class EntityResolver extends AbstractOptions { /** @@ -55,8 +53,8 @@ public function setResolvers(array $resolvers): void sprintf( '%s is resolved to the entity %s, which does not exist', $old, - $new - ) + $new, + ), ); } @@ -64,9 +62,7 @@ public function setResolvers(array $resolvers): void } } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getResolvers(): array { return $this->resolvers; diff --git a/src/Options/SQLLoggerCollectorOptions.php b/src/Options/SQLLoggerCollectorOptions.php index 4969ac7f..eea99d15 100644 --- a/src/Options/SQLLoggerCollectorOptions.php +++ b/src/Options/SQLLoggerCollectorOptions.php @@ -17,12 +17,12 @@ final class SQLLoggerCollectorOptions extends AbstractOptions protected string $name = 'orm_default'; /** @var string|null service name of the configuration where the logger has to be put */ - protected ?string $configuration = null; + protected string|null $configuration = null; /** @var string|null service name of the SQLLogger to be used */ - protected ?string $sqlLogger = null; + protected string|null $sqlLogger = null; - public function setName(?string $name): void + public function setName(string|null $name): void { $this->name = (string) $name; } @@ -35,7 +35,7 @@ public function getName(): string return $this->name; } - public function setConfiguration(?string $configuration): void + public function setConfiguration(string|null $configuration): void { $this->configuration = $configuration ?: null; } @@ -48,7 +48,7 @@ public function getConfiguration(): string return $this->configuration ?: 'doctrine.configuration.orm_default'; } - public function setSqlLogger(?string $sqlLogger): void + public function setSqlLogger(string|null $sqlLogger): void { $this->sqlLogger = $sqlLogger ?: null; } @@ -56,7 +56,7 @@ public function setSqlLogger(?string $sqlLogger): void /** * SQLLogger service name */ - public function getSqlLogger(): ?string + public function getSqlLogger(): string|null { return $this->sqlLogger; } diff --git a/src/Options/SecondLevelCacheConfiguration.php b/src/Options/SecondLevelCacheConfiguration.php index 08b4883f..89b5d6a6 100644 --- a/src/Options/SecondLevelCacheConfiguration.php +++ b/src/Options/SecondLevelCacheConfiguration.php @@ -84,17 +84,13 @@ public function getFileLockRegionDirectory(): string return $this->fileLockRegionDirectory; } - /** - * @param mixed[] $regions - */ + /** @param mixed[] $regions */ public function setRegions(array $regions): void { $this->regions = $regions; } - /** - * @return mixed[] - */ + /** @return mixed[] */ public function getRegions(): array { return $this->regions; diff --git a/src/Paginator/Adapter/DoctrinePaginator.php b/src/Paginator/Adapter/DoctrinePaginator.php index b526ec87..c3f79f99 100644 --- a/src/Paginator/Adapter/DoctrinePaginator.php +++ b/src/Paginator/Adapter/DoctrinePaginator.php @@ -12,29 +12,23 @@ /** * Paginator adapter for the Laminas\Paginator component * - * @psalm-template T of object - * @psalm-template TKey of int - * @psalm-template TValue + * @phpstan-template T of object + * @phpstan-template TKey of int + * @phpstan-template TValue * @template-implements AdapterInterface */ class DoctrinePaginator implements AdapterInterface, JsonSerializable { - /** @var Paginator */ - protected Paginator $paginator; - /** * Constructor * * @param Paginator $paginator */ - public function __construct(Paginator $paginator) + public function __construct(protected Paginator $paginator) { - $this->paginator = $paginator; } - /** - * @param Paginator $paginator - */ + /** @param Paginator $paginator */ public function setPaginator(Paginator $paginator): self { $this->paginator = $paginator; @@ -42,9 +36,7 @@ public function setPaginator(Paginator $paginator): self return $this; } - /** - * @return Paginator - */ + /** @return Paginator */ public function getPaginator(): Paginator { return $this->paginator; @@ -57,8 +49,6 @@ public function getPaginator(): Paginator * @param int|null $itemCountPerPage * * @return ArrayIterator - * - * @psalm-suppress LessSpecificImplementedReturnType */ public function getItems($offset, $itemCountPerPage) { @@ -75,9 +65,7 @@ public function count(): int return $this->paginator->count(); } - /** - * @return array{select: list|string, count_select: int} - */ + /** @return array{select: list|string, count_select: int} */ public function jsonSerialize(): array { return [ diff --git a/src/Service/CliConfiguratorFactory.php b/src/Service/CliConfiguratorFactory.php index 6444526c..4b9017fd 100644 --- a/src/Service/CliConfiguratorFactory.php +++ b/src/Service/CliConfiguratorFactory.php @@ -13,7 +13,7 @@ final class CliConfiguratorFactory implements FactoryInterface /** * {@inheritDoc} */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { return new CliConfigurator($serviceLocator); } diff --git a/src/Service/ConfigurationFactory.php b/src/Service/ConfigurationFactory.php index 775bdc99..9cde5734 100644 --- a/src/Service/ConfigurationFactory.php +++ b/src/Service/ConfigurationFactory.php @@ -27,7 +27,7 @@ final class ConfigurationFactory extends DoctrineConfigurationFactory * * @return Configuration */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { $options = $this->getOptions($serviceLocator); $config = new Configuration(); @@ -97,7 +97,7 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?ar if (is_string($repositoryFactory)) { if (! $serviceLocator->has($repositoryFactory)) { throw new InvalidArgumentException( - sprintf('Repository factory "%s" not found', $repositoryFactory) + sprintf('Repository factory "%s" not found', $repositoryFactory), ); } @@ -121,7 +121,7 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?ar if ($secondLevelCache->isEnabled()) { $regionsConfig = new RegionsConfiguration( $secondLevelCache->getDefaultLifetime(), - $secondLevelCache->getDefaultLockLifetime() + $secondLevelCache->getDefaultLockLifetime(), ); foreach ($secondLevelCache->getRegions() as $regionName => $regionConfig) { diff --git a/src/Service/DBALConfigurationFactory.php b/src/Service/DBALConfigurationFactory.php index b62c0e5d..78152753 100644 --- a/src/Service/DBALConfigurationFactory.php +++ b/src/Service/DBALConfigurationFactory.php @@ -23,11 +23,8 @@ */ class DBALConfigurationFactory implements FactoryInterface { - protected string $name; - - public function __construct(string $name) + public function __construct(protected string $name) { - $this->name = $name; } /** @@ -37,7 +34,7 @@ public function __construct(string $name) * * @return Configuration */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { $config = new Configuration(); $this->setupDBALConfiguration($serviceLocator, $config); @@ -88,9 +85,7 @@ public function setupDBALConfiguration(ContainerInterface $serviceLocator, Confi } } - /** - * @throws RuntimeException - */ + /** @throws RuntimeException */ public function getOptions(ContainerInterface $serviceLocator): mixed { $options = $serviceLocator->get('config'); @@ -101,8 +96,8 @@ public function getOptions(ContainerInterface $serviceLocator): mixed throw new RuntimeException( sprintf( 'Configuration with name "%s" could not be found in "doctrine.configuration".', - $this->name - ) + $this->name, + ), ); } diff --git a/src/Service/DBALConnectionFactory.php b/src/Service/DBALConnectionFactory.php index dc6f1a37..6e01531d 100644 --- a/src/Service/DBALConnectionFactory.php +++ b/src/Service/DBALConnectionFactory.php @@ -29,7 +29,7 @@ final class DBALConnectionFactory extends AbstractFactory * * @return Connection */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { $options = $this->getOptions($serviceLocator, 'connection'); assert($options instanceof DBALConnection); @@ -58,7 +58,6 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?ar $configuration = $serviceLocator->get($options->getConfiguration()); $eventManager = $serviceLocator->get($options->getEventManager()); - /** @psalm-suppress InvalidArgument */ $connection = DriverManager::getConnection($params, $configuration, $eventManager); foreach ($options->getDoctrineTypeMappings() as $dbType => $doctrineType) { $connection->getDatabasePlatform()->registerDoctrineTypeMapping($dbType, $doctrineType); diff --git a/src/Service/DoctrineObjectHydratorFactory.php b/src/Service/DoctrineObjectHydratorFactory.php index 1e0f20a6..d894f7cc 100644 --- a/src/Service/DoctrineObjectHydratorFactory.php +++ b/src/Service/DoctrineObjectHydratorFactory.php @@ -13,7 +13,7 @@ final class DoctrineObjectHydratorFactory implements FactoryInterface /** * {@inheritDoc} */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { return new DoctrineObject($serviceLocator->get('doctrine.entitymanager.orm_default')); } diff --git a/src/Service/EntityManagerAliasCompatFactory.php b/src/Service/EntityManagerAliasCompatFactory.php index 58288b71..8aaa6c95 100644 --- a/src/Service/EntityManagerAliasCompatFactory.php +++ b/src/Service/EntityManagerAliasCompatFactory.php @@ -23,7 +23,7 @@ final class EntityManagerAliasCompatFactory implements FactoryInterface * * @return EntityManager */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { return $serviceLocator->get('doctrine.entitymanager.orm_default'); } diff --git a/src/Service/EntityManagerFactory.php b/src/Service/EntityManagerFactory.php index 0693aeee..8c4f29ad 100644 --- a/src/Service/EntityManagerFactory.php +++ b/src/Service/EntityManagerFactory.php @@ -20,7 +20,7 @@ final class EntityManagerFactory extends AbstractFactory * * @return EntityManager */ - public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, array|null $options = null) { $options = $this->getOptions($container, 'entitymanager'); assert($options instanceof DoctrineORMModuleEntityManager); diff --git a/src/Service/EntityResolverFactory.php b/src/Service/EntityResolverFactory.php index 67ada77e..1f4ade01 100644 --- a/src/Service/EntityResolverFactory.php +++ b/src/Service/EntityResolverFactory.php @@ -16,7 +16,7 @@ final class EntityResolverFactory extends AbstractFactory /** * {@inheritDoc} */ - public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, array|null $options = null) { $options = $this->getOptions($container, 'entity_resolver'); assert($options instanceof EntityResolver); diff --git a/src/Service/MappingCollectorFactory.php b/src/Service/MappingCollectorFactory.php index 69e54754..c7a323c6 100644 --- a/src/Service/MappingCollectorFactory.php +++ b/src/Service/MappingCollectorFactory.php @@ -21,7 +21,7 @@ final class MappingCollectorFactory extends AbstractFactory * * @return MappingCollector */ - public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $container, $requestedName, array|null $options = null) { $name = $this->getName(); $objectManager = $container->get('doctrine.entitymanager.' . $name); diff --git a/src/Service/MigrationsCommandFactory.php b/src/Service/MigrationsCommandFactory.php index ffa70696..5e1cfa6a 100644 --- a/src/Service/MigrationsCommandFactory.php +++ b/src/Service/MigrationsCommandFactory.php @@ -59,7 +59,7 @@ public function __construct(string $name) * * @throws InvalidArgumentException */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { $commandClassName = $this->commandClassName; @@ -75,7 +75,7 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?ar ! preg_match( '/^doctrine\.((?orm|odm)\.|)(?[a-z0-9_]+)\.(?[a-z0-9_]+)$/', $objectManagerName, - $matches + $matches, ) ) { throw new RuntimeException('The object manager name is invalid: ' . $objectManagerName); @@ -91,7 +91,7 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?ar $dependencyFactory = DependencyFactory::fromEntityManager( new ConfigurationArray($migrationConfig), - new ExistingEntityManager($serviceLocator->get($objectManagerName)) + new ExistingEntityManager($serviceLocator->get($objectManagerName)), ); foreach ($dependencyFactoryServices as $id => $service) { @@ -111,7 +111,6 @@ private function getObjectManagerName(): string return $this->defaultObjectManagerName; } - /** @psalm-suppress ReservedWord */ return $arguments->getParameterOption('--object-manager'); } } diff --git a/src/Service/ObjectMultiCheckboxFactory.php b/src/Service/ObjectMultiCheckboxFactory.php index 26085749..dd70e139 100644 --- a/src/Service/ObjectMultiCheckboxFactory.php +++ b/src/Service/ObjectMultiCheckboxFactory.php @@ -21,7 +21,7 @@ final class ObjectMultiCheckboxFactory implements FactoryInterface * * @return ObjectMultiCheckbox */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { $entityManager = $serviceLocator->get(EntityManager::class); $element = new ObjectMultiCheckbox(); diff --git a/src/Service/ObjectRadioFactory.php b/src/Service/ObjectRadioFactory.php index f3152519..8b692eb3 100644 --- a/src/Service/ObjectRadioFactory.php +++ b/src/Service/ObjectRadioFactory.php @@ -21,7 +21,7 @@ final class ObjectRadioFactory implements FactoryInterface * * @return ObjectRadio */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { $entityManager = $serviceLocator->get(EntityManager::class); $element = new ObjectRadio(); diff --git a/src/Service/ObjectSelectFactory.php b/src/Service/ObjectSelectFactory.php index 979eadb2..0d2ca490 100644 --- a/src/Service/ObjectSelectFactory.php +++ b/src/Service/ObjectSelectFactory.php @@ -21,7 +21,7 @@ final class ObjectSelectFactory implements FactoryInterface * * @return ObjectSelect */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { $entityManager = $serviceLocator->get(EntityManager::class); $element = new ObjectSelect(); diff --git a/src/Service/ReservedWordsCommandFactory.php b/src/Service/ReservedWordsCommandFactory.php index e6aefb3d..7a27a754 100644 --- a/src/Service/ReservedWordsCommandFactory.php +++ b/src/Service/ReservedWordsCommandFactory.php @@ -14,10 +14,10 @@ final class ReservedWordsCommandFactory implements FactoryInterface /** * {@inheritDoc} */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { return new ReservedWordsCommand( - new SingleConnectionProvider($serviceLocator->get('doctrine.connection.orm_default')) + new SingleConnectionProvider($serviceLocator->get('doctrine.connection.orm_default')), ); } } diff --git a/src/Service/RunSqlCommandFactory.php b/src/Service/RunSqlCommandFactory.php index cf3c3b3e..607c41b2 100644 --- a/src/Service/RunSqlCommandFactory.php +++ b/src/Service/RunSqlCommandFactory.php @@ -14,10 +14,10 @@ final class RunSqlCommandFactory implements FactoryInterface /** * {@inheritDoc} */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { return new RunSqlCommand( - new SingleConnectionProvider($serviceLocator->get('doctrine.connection.orm_default')) + new SingleConnectionProvider($serviceLocator->get('doctrine.connection.orm_default')), ); } } diff --git a/src/Service/SQLLoggerCollectorFactory.php b/src/Service/SQLLoggerCollectorFactory.php index 17969416..e7ebbfb9 100644 --- a/src/Service/SQLLoggerCollectorFactory.php +++ b/src/Service/SQLLoggerCollectorFactory.php @@ -19,17 +19,14 @@ */ final class SQLLoggerCollectorFactory implements FactoryInterface { - protected string $name; - - public function __construct(string $name) + public function __construct(protected string $name) { - $this->name = $name; } /** * {@inheritDoc} */ - public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?array $options = null) + public function __invoke(ContainerInterface $serviceLocator, $requestedName, array|null $options = null) { $options = $this->getOptions($serviceLocator); @@ -55,9 +52,7 @@ public function __invoke(ContainerInterface $serviceLocator, $requestedName, ?ar return new SQLLoggerCollector($debugStackLogger, 'doctrine.sql_logger_collector.' . $options->getName()); } - /** - * @throws RuntimeException - */ + /** @throws RuntimeException */ protected function getOptions(ContainerInterface $serviceLocator): mixed { $options = $serviceLocator->get('config'); @@ -68,8 +63,8 @@ protected function getOptions(ContainerInterface $serviceLocator): mixed throw new RuntimeException( sprintf( 'Configuration with name "%s" could not be found in "doctrine.sql_logger_collector".', - $this->name - ) + $this->name, + ), ); } @@ -78,9 +73,7 @@ protected function getOptions(ContainerInterface $serviceLocator): mixed return new $optionsClass($options); } - /** - * @psalm-return class-string - */ + /** @phpstan-return class-string */ protected function getOptionsClass(): string { return SQLLoggerCollectorOptions::class; diff --git a/src/Yuml/MetadataGrapher.php b/src/Yuml/MetadataGrapher.php index b7d3a403..bb88383b 100644 --- a/src/Yuml/MetadataGrapher.php +++ b/src/Yuml/MetadataGrapher.php @@ -121,7 +121,7 @@ private function getAssociationString(ClassMetadata $class1, string $association . $this->getClassString($class2); } - private function getClassReverseAssociationName(ClassMetadata $class1, ClassMetadata $class2): ?string + private function getClassReverseAssociationName(ClassMetadata $class1, ClassMetadata $class2): string|null { foreach ($class2->getAssociationNames() as $class2Side) { $targetClass = $this->getClassByName($class2->getAssociationTargetClass($class2Side)); @@ -174,7 +174,7 @@ private function getClassString(ClassMetadata $class): string /** * Retrieve a class metadata instance by name from the given array */ - private function getClassByName(string $className): ?ClassMetadata + private function getClassByName(string $className): ClassMetadata|null { if (! isset($this->classByNames[$className])) { foreach ($this->metadata as $class) { @@ -191,7 +191,7 @@ private function getClassByName(string $className): ?ClassMetadata /** * Retrieve a class metadata's parent class metadata */ - private function getParent(ClassMetadata $class): ?ClassMetadata + private function getParent(ClassMetadata $class): ClassMetadata|null { $className = $class->getName(); if (! class_exists($className)) { @@ -209,11 +209,11 @@ private function getParent(ClassMetadata $class): ?ClassMetadata /** * Visit a given association and mark it as visited * - * @psalm-param class-string $className + * @phpstan-param class-string $className * * @return bool true if the association was visited before */ - private function visitAssociation(string $className, ?string $association = null): bool + private function visitAssociation(string $className, string|null $association = null): bool { if ($association === null) { if (isset($this->visitedAssociations[$className])) { diff --git a/src/Yuml/YumlController.php b/src/Yuml/YumlController.php index 2f87c886..aa7933bd 100644 --- a/src/Yuml/YumlController.php +++ b/src/Yuml/YumlController.php @@ -17,11 +17,8 @@ */ class YumlController extends AbstractActionController { - protected Client $httpClient; - - public function __construct(Client $httpClient) + public function __construct(protected Client $httpClient) { - $this->httpClient = $httpClient; } /** diff --git a/src/Yuml/YumlControllerFactory.php b/src/Yuml/YumlControllerFactory.php index d859513a..127a8086 100644 --- a/src/Yuml/YumlControllerFactory.php +++ b/src/Yuml/YumlControllerFactory.php @@ -21,7 +21,7 @@ class YumlControllerFactory implements FactoryInterface public function __invoke( ContainerInterface $container, $requestedName, - ?array $options = null + array|null $options = null, ): YumlController { $config = $container->get('config'); @@ -30,12 +30,12 @@ public function __invoke( || ! $config['laminas-developer-tools']['toolbar']['enabled'] ) { throw new ServiceNotFoundException( - sprintf('Service %s could not be found', YumlController::class) + sprintf('Service %s could not be found', YumlController::class), ); } return new YumlController( - new Client('https://yuml.me/diagram/plain/class/', ['timeout' => 30]) + new Client('https://yuml.me/diagram/plain/class/', ['timeout' => 30]), ); } } diff --git a/tests/Assets/Entity/Category.php b/tests/Assets/Entity/Category.php index 1a16f573..8c9e5995 100644 --- a/tests/Assets/Entity/Category.php +++ b/tests/Assets/Entity/Category.php @@ -22,7 +22,7 @@ class Category /** @ORM\Column(type="string", nullable=true) */ protected string $name; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/City.php b/tests/Assets/Entity/City.php index 7dc8684f..cafa232f 100644 --- a/tests/Assets/Entity/City.php +++ b/tests/Assets/Entity/City.php @@ -25,7 +25,7 @@ class City /** @ORM\OneToOne(targetEntity="Country") */ protected Country $country; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/Country.php b/tests/Assets/Entity/Country.php index 882ad81b..d50aea0d 100644 --- a/tests/Assets/Entity/Country.php +++ b/tests/Assets/Entity/Country.php @@ -22,7 +22,7 @@ class Country /** @ORM\Column(type="string", nullable=true) */ protected string $name; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/Date.php b/tests/Assets/Entity/Date.php index b7a09a3f..8b45b761 100644 --- a/tests/Assets/Entity/Date.php +++ b/tests/Assets/Entity/Date.php @@ -23,7 +23,7 @@ class Date /** @ORM\Column(type="date", nullable=true) */ protected DateTime $date; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/EntityWithoutRepository.php b/tests/Assets/Entity/EntityWithoutRepository.php index 2a902425..c8f75ca2 100644 --- a/tests/Assets/Entity/EntityWithoutRepository.php +++ b/tests/Assets/Entity/EntityWithoutRepository.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +/** @ORM\Entity */ class EntityWithoutRepository { /** @@ -16,9 +14,9 @@ class EntityWithoutRepository * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ - private ?int $id = null; + private int|null $id = null; - public function getId(): ?int + public function getId(): int|null { return $this->id; } diff --git a/tests/Assets/Entity/FormEntity.php b/tests/Assets/Entity/FormEntity.php index 0e082771..34c3a166 100644 --- a/tests/Assets/Entity/FormEntity.php +++ b/tests/Assets/Entity/FormEntity.php @@ -64,7 +64,7 @@ class FormEntity protected string $string; /** @ORM\Column(type="string", nullable=true) */ - protected ?string $stringNullable = null; + protected string|null $stringNullable = null; /** @ORM\OneToOne(targetEntity="Target") */ protected Target $targetOne; @@ -73,7 +73,7 @@ class FormEntity * @ORM\OneToOne(targetEntity="Target") * @ORM\JoinColumn(nullable=true) */ - protected ?Target $targetOneNullable = null; + protected Target|null $targetOneNullable = null; /** * @ORM\OneToOne(targetEntity="Target") @@ -82,7 +82,7 @@ class FormEntity * @Form\Type("DoctrineModule\Form\Element\ObjectSelect") * @Form\Options({"empty_option":null}) */ - protected ?Target $noDisplayEmptyOption = null; + protected Target|null $noDisplayEmptyOption = null; /** * @ORM\OneToMany(targetEntity="FormEntityTarget", mappedBy="formEntity") diff --git a/tests/Assets/Entity/FormEntityTarget.php b/tests/Assets/Entity/FormEntityTarget.php index 08676bf7..d5dc8d55 100644 --- a/tests/Assets/Entity/FormEntityTarget.php +++ b/tests/Assets/Entity/FormEntityTarget.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +/** @ORM\Entity */ class FormEntityTarget { /** diff --git a/tests/Assets/Entity/Product.php b/tests/Assets/Entity/Product.php index a8cdba17..a1481c92 100644 --- a/tests/Assets/Entity/Product.php +++ b/tests/Assets/Entity/Product.php @@ -29,7 +29,7 @@ class Product */ protected array $categories; - public function getId(): ?int + public function getId(): int|null { return $this->id; } @@ -46,9 +46,7 @@ public function getName(): string return $this->name; } - /** - * @param Category[] $categories - */ + /** @param Category[] $categories */ public function setCategories(array $categories): self { $this->categories = $categories; @@ -56,9 +54,7 @@ public function setCategories(array $categories): self return $this; } - /** - * @return Category[] - */ + /** @return Category[] */ public function getCategories(): array { return $this->categories; diff --git a/tests/Assets/Entity/ResolveTarget.php b/tests/Assets/Entity/ResolveTarget.php index 1c2a43f6..a74901f1 100644 --- a/tests/Assets/Entity/ResolveTarget.php +++ b/tests/Assets/Entity/ResolveTarget.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +/** @ORM\Entity */ class ResolveTarget { /** diff --git a/tests/Assets/Entity/TargetEntity.php b/tests/Assets/Entity/TargetEntity.php index d252c78a..1412fd9b 100644 --- a/tests/Assets/Entity/TargetEntity.php +++ b/tests/Assets/Entity/TargetEntity.php @@ -6,9 +6,7 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +/** @ORM\Entity */ class TargetEntity implements Target { /** diff --git a/tests/Assets/Entity/Test.php b/tests/Assets/Entity/TestEntity.php similarity index 87% rename from tests/Assets/Entity/Test.php rename to tests/Assets/Entity/TestEntity.php index 93a2274c..e5a086e9 100644 --- a/tests/Assets/Entity/Test.php +++ b/tests/Assets/Entity/TestEntity.php @@ -10,7 +10,7 @@ * @ORM\Entity * @ORM\Table(name="doctrine_orm_module_test") */ -class Test +class TestEntity { /** * @ORM\Id @@ -25,7 +25,7 @@ class Test /** @ORM\Column(type="string", nullable=true) */ protected string $password; - public function getId(): ?int + public function getId(): int|null { return $this->id; } @@ -35,7 +35,7 @@ public function setPassword(string $password): void $this->password = (string) $password; } - public function getPassword(): ?string + public function getPassword(): string|null { return $this->password; } @@ -45,7 +45,7 @@ public function setUsername(string $username): void $this->username = (string) $username; } - public function getUsername(): ?string + public function getUsername(): string|null { return $this->username; } diff --git a/tests/Assets/Fixture/TestFixture.php b/tests/Assets/Fixture/TestFixture.php index 16d38618..3e27b156 100644 --- a/tests/Assets/Fixture/TestFixture.php +++ b/tests/Assets/Fixture/TestFixture.php @@ -8,7 +8,7 @@ use Doctrine\Persistence\ObjectManager; use DoctrineORMModuleTest\Assets\Entity\Category; use DoctrineORMModuleTest\Assets\Entity\Country; -use DoctrineORMModuleTest\Assets\Entity\Test as TestEntity; +use DoctrineORMModuleTest\Assets\Entity\TestEntity; /** * Fixture that loads a constant amount of \DoctrineORMModuleTest\Assets\Entity\Test objects into the manager diff --git a/tests/Assets/Types/MoneyType.php b/tests/Assets/Types/MoneyType.php index dbeff35e..a4fb35ea 100644 --- a/tests/Assets/Types/MoneyType.php +++ b/tests/Assets/Types/MoneyType.php @@ -15,9 +15,7 @@ class MoneyType extends Type { public const MONEY = 'money'; - /** - * @param mixed[] $fieldDeclaration - */ + /** @param mixed[] $fieldDeclaration */ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string { return 'MyMoney'; diff --git a/tests/CliConfiguratorTest.php b/tests/CliConfiguratorTest.php index 2a769a9a..c37b6b7f 100644 --- a/tests/CliConfiguratorTest.php +++ b/tests/CliConfiguratorTest.php @@ -5,10 +5,8 @@ namespace DoctrineORMModuleTest\Listener; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Tools\Console\Command\ImportCommand; use Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand; use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand; -use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper; use Doctrine\Migrations\Tools\Console\Command\DiffCommand; use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand; use Doctrine\Migrations\Tools\Console\Command\GenerateCommand; @@ -30,14 +28,11 @@ use Laminas\ServiceManager\ServiceManager; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; use function assert; use function class_exists; -/** - * @link http://www.doctrine-project.org/ - */ +/** @link http://www.doctrine-project.org/ */ class CliConfiguratorTest extends TestCase { protected ServiceManager $serviceManager; @@ -64,9 +59,7 @@ public function testOrmDefaultIsUsedAsTheEntityManagerIfNoneIsProvided(): void $this->assertSame($this->objectManager, $entityManagerHelper->getEntityManager()); } - /** - * @backupGlobals enabled - */ + /** @backupGlobals enabled */ public function testEntityManagerUsedCanBeSpecifiedInCommandLineArgument(): void { $objectManagerName = 'doctrine.entitymanager.some_other_name'; @@ -112,25 +105,14 @@ public function testValidHelpers(): void assert($emHelper instanceof EntityManagerHelper); $this->assertInstanceOf(EntityManagerHelper::class, $emHelper); $this->assertSame($this->objectManager, $emHelper->getEntityManager()); - - if (! class_exists(ConnectionHelper::class)) { - return; - } - - $dbHelper = $helperSet->get('db'); - assert($dbHelper instanceof ConnectionHelper); - $this->assertInstanceOf(ConnectionHelper::class, $dbHelper); - $this->assertSame($this->objectManager->getConnection(), $dbHelper->getConnection()); } - /** - * @dataProvider dataProviderForTestValidCommands - */ + /** @dataProvider dataProviderForTestValidCommands */ public function testValidCommands(string $commandName, string $className): void { if (! class_exists(VersionCommand::class)) { $this->markTestIncomplete( - 'Migrations must be installed to run this test.' + 'Migrations must be installed to run this test.', ); } @@ -140,7 +122,6 @@ public function testValidCommands(string $commandName, string $className): void $cliConfigurator->configure($application); $command = $application->get($commandName); - assert($command instanceof Command); $this->assertInstanceOf($className, $command); // check for the entity-manager option @@ -156,12 +137,10 @@ public function testValidCommands(string $commandName, string $className): void $this->assertSame('The name of the object manager to use.', $entityManagerOption->getDescription()); } - /** - * @return list - */ + /** @return list */ public function dataProviderForTestValidCommands(): array { - $data = [ + return [ [ 'dbal:run-sql', RunSqlCommand::class, @@ -223,15 +202,5 @@ public function dataProviderForTestValidCommands(): array ExecuteCommand::class, ], ]; - - // this is only available with DBAL 2.x - if (class_exists(ImportCommand::class)) { - $data[] = [ - 'dbal:import', - ImportCommand::class, - ]; - } - - return $data; } } diff --git a/tests/Collector/MappingCollectorTest.php b/tests/Collector/MappingCollectorTest.php index 15a36ed6..98783d7b 100644 --- a/tests/Collector/MappingCollectorTest.php +++ b/tests/Collector/MappingCollectorTest.php @@ -20,14 +20,11 @@ */ class MappingCollectorTest extends TestCase { - /** @var ClassMetadataFactory&MockObject */ - protected $metadataFactory; + protected ClassMetadataFactory&MockObject $metadataFactory; protected MappingCollector $collector; - /** - * @covers \DoctrineORMModule\Collector\MappingCollector::__construct - */ + /** @covers \DoctrineORMModule\Collector\MappingCollector::__construct */ public function setUp(): void { parent::setUp(); @@ -36,17 +33,13 @@ public function setUp(): void $this->collector = new MappingCollector($this->metadataFactory, 'test-collector'); } - /** - * @covers \DoctrineORMModule\Collector\MappingCollector::getName - */ + /** @covers \DoctrineORMModule\Collector\MappingCollector::getName */ public function testGetName(): void { $this->assertSame('test-collector', $this->collector->getName()); } - /** - * @covers \DoctrineORMModule\Collector\MappingCollector::getPriority - */ + /** @covers \DoctrineORMModule\Collector\MappingCollector::getPriority */ public function testGetPriority(): void { $this->assertIsInt($this->collector->getPriority()); @@ -77,9 +70,7 @@ public function testCollect(): void $this->assertSame($classes['M2'], $m2); } - /** - * @covers \DoctrineORMModule\Collector\MappingCollector::canHide - */ + /** @covers \DoctrineORMModule\Collector\MappingCollector::canHide */ public function testCanHide(): void { $this->assertTrue($this->collector->canHide()); @@ -94,8 +85,8 @@ public function testCanHide(): void } /** - * @covers \DoctrineORMModule\Collector\MappingCollector::serialize - * @covers \DoctrineORMModule\Collector\MappingCollector::unserialize + * @covers \DoctrineORMModule\Collector\MappingCollector::__serialize + * @covers \DoctrineORMModule\Collector\MappingCollector::__unserialize * @covers \DoctrineORMModule\Collector\MappingCollector::collect */ public function testSerializeUnserializeAndCollectWithNoMetadataFactory(): void diff --git a/tests/Collector/SQLLoggerCollectorTest.php b/tests/Collector/SQLLoggerCollectorTest.php index 37d7431a..1bb902c8 100644 --- a/tests/Collector/SQLLoggerCollectorTest.php +++ b/tests/Collector/SQLLoggerCollectorTest.php @@ -23,6 +23,7 @@ class SQLLoggerCollectorTest extends TestCase public function setUp(): void { parent::setUp(); + $this->logger = new DebugStack(); $this->collector = new SQLLoggerCollector($this->logger, $this->name); } diff --git a/tests/Form/Annotation/DoctrineAnnotationListenerTest.php b/tests/Form/Annotation/DoctrineAnnotationListenerTest.php index df6e9d3f..de8b9f8d 100644 --- a/tests/Form/Annotation/DoctrineAnnotationListenerTest.php +++ b/tests/Form/Annotation/DoctrineAnnotationListenerTest.php @@ -29,9 +29,7 @@ public function setUp(): void $this->listener = new DoctrineAnnotationListener($this->getEntityManager()); } - /** - * @dataProvider eventNameProvider - */ + /** @dataProvider eventNameProvider */ public function testEventsWithNoMetadata(string $method): void { $event = $this->getMetadataEvent(); @@ -52,7 +50,7 @@ public function testToOne(): void $this->assertEquals($this->getEntityManager(), $elementSpec['spec']['options']['object_manager']); $this->assertEquals( TargetEntity::class, - $elementSpec['spec']['options']['target_class'] + $elementSpec['spec']['options']['target_class'], ); $this->assertEquals(EntitySelect::class, $elementSpec['spec']['type']); } @@ -61,9 +59,7 @@ public function testToOneMergesOptions(): void { $listener = $this->listener; $event = $this->getMetadataEvent(); - /** - * @var ArrayObject> - */ + /** @var ArrayObject> $elementSpec */ $elementSpec = new ArrayObject(); $elementSpec['spec']['options']['foo'] = 'bar'; @@ -114,7 +110,7 @@ public function testToMany(): void $this->assertEquals($this->getEntityManager(), $elementSpec['spec']['options']['object_manager']); $this->assertEquals( FormEntityTarget::class, - $elementSpec['spec']['options']['target_class'] + $elementSpec['spec']['options']['target_class'], ); $this->assertEquals(EntitySelect::class, $elementSpec['spec']['type']); $this->assertFalse($inputSpec['required']); @@ -124,9 +120,7 @@ public function testToManyMergesOptions(): void { $listener = $this->listener; $event = $this->getMetadataEvent(); - /** - * @var ArrayObject> - */ + /** @var ArrayObject> $elementSpec */ $elementSpec = new ArrayObject(); $elementSpec['spec']['options']['foo'] = 'bar'; @@ -150,9 +144,7 @@ public function testHandleExcludeAssociation(): void $this->assertFalse($listener->handleExcludeAssociation($event)); } - /** - * @dataProvider eventFilterProvider - */ + /** @dataProvider eventFilterProvider */ public function testHandleFilterField(string $name, string $type): void { $listener = $this->listener; @@ -230,9 +222,7 @@ public function testHandleRequiredFieldNonFieldProperty(): void $this->assertFalse(isset($inputSpec['required'])); } - /** - * @dataProvider eventTypeProvider - */ + /** @dataProvider eventTypeProvider */ public function testHandleTypeField(string $name, string $type): void { $listener = $this->listener; @@ -249,10 +239,8 @@ public function testHandleTypeField(string $name, string $type): void $this->assertEquals($type, $elementSpec['spec']['type']); } - /** - * @dataProvider eventValidatorProvider - */ - public function testHandleValidatorField(string $name, ?string $type): void + /** @dataProvider eventValidatorProvider */ + public function testHandleValidatorField(string $name, string|null $type): void { $listener = $this->listener; $event = $this->getMetadataEvent(); @@ -273,10 +261,8 @@ public function testHandleValidatorField(string $name, ?string $type): void } } - /** - * @return list - */ - public function eventValidatorProvider() + /** @return list */ + public function eventValidatorProvider(): array { return [ ['bool', 'InArray'], @@ -295,10 +281,8 @@ public function eventValidatorProvider() ]; } - /** - * @return list - */ - public function eventFilterProvider() + /** @return list */ + public function eventFilterProvider(): array { return [ ['bool', 'Boolean'], @@ -317,10 +301,8 @@ public function eventFilterProvider() ]; } - /** - * @return list - */ - public function eventTypeProvider() + /** @return list */ + public function eventTypeProvider(): array { return [ ['bool', Checkbox::class], @@ -339,9 +321,7 @@ public function eventTypeProvider() ]; } - /** - * @return list - */ + /** @return list */ public function eventNameProvider(): array { return [ diff --git a/tests/Form/Annotation/EntityBasedFormBuilderTest.php b/tests/Form/Annotation/EntityBasedFormBuilderTest.php index 4b845b47..bd0881a8 100644 --- a/tests/Form/Annotation/EntityBasedFormBuilderTest.php +++ b/tests/Form/Annotation/EntityBasedFormBuilderTest.php @@ -26,16 +26,14 @@ public function setUp(): void if (! class_exists(AbstractBuilder::class)) { $this->markTestSkipped(sprintf( '%s requires laminas-form 3.0.0 or newer to be installed.', - EntityBasedFormBuilder::class + EntityBasedFormBuilder::class, )); } $this->builder = new EntityBasedFormBuilder($this->getEntityManager()); } - /** - * @link https://github.com/doctrine/DoctrineORMModule/issues/237 - */ + /** @link https://github.com/doctrine/DoctrineORMModule/issues/237 */ public function testIssue237(): void { $entity = new Issue237(); @@ -120,9 +118,7 @@ public function testEnsureCustomTypeOrAttributeTypeIsUsedInAnnotations(): void $this->assertTrue($userDefinedTypeOverridesListenerType); } - /** - * @link https://github.com/zendframework/zf2/issues/7096 - */ + /** @link https://github.com/zendframework/zf2/issues/7096 */ public function testFileTypeDoesntGrabStringLengthValidator(): void { $validators = $this diff --git a/tests/Framework/TestCase.php b/tests/Framework/TestCase.php index deab00f8..4bef707d 100644 --- a/tests/Framework/TestCase.php +++ b/tests/Framework/TestCase.php @@ -16,7 +16,7 @@ class TestCase extends PHPUnitTestCase { protected bool $hasDb = false; - private ?EntityManager $entityManager = null; + private EntityManager|null $entityManager = null; /** * Creates a database if not done already. diff --git a/tests/Options/DBALConnectionTest.php b/tests/Options/DBALConnectionTest.php index 99bc7656..c00bcc4d 100644 --- a/tests/Options/DBALConnectionTest.php +++ b/tests/Options/DBALConnectionTest.php @@ -7,9 +7,7 @@ use DoctrineORMModule\Options\DBALConnection; use PHPUnit\Framework\TestCase; -/** - * @covers \DoctrineORMModule\Options\DBALConnection - */ +/** @covers \DoctrineORMModule\Options\DBALConnection */ class DBALConnectionTest extends TestCase { public function testSetNullCommentedTypes(): void diff --git a/tests/Paginator/AdapterTest.php b/tests/Paginator/AdapterTest.php index 0cf5db9a..f0b50687 100644 --- a/tests/Paginator/AdapterTest.php +++ b/tests/Paginator/AdapterTest.php @@ -10,7 +10,7 @@ use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\Tools\Pagination\Paginator as DoctrinePaginator; use DoctrineORMModule\Paginator\Adapter\DoctrinePaginator as PaginatorAdapter; -use DoctrineORMModuleTest\Assets\Entity\Test; +use DoctrineORMModuleTest\Assets\Entity\TestEntity; use DoctrineORMModuleTest\Assets\Fixture\TestFixture; use DoctrineORMModuleTest\Framework\TestCase; @@ -31,7 +31,7 @@ public function setUp(): void if (! class_exists(FixtureLoader::class)) { $this->markTestIncomplete( - 'DataFixtures must be installed to run this test.' + 'DataFixtures must be installed to run this test.', ); } @@ -46,7 +46,7 @@ public function setUp(): void ->getEntityManager() ->createQueryBuilder() ->select('t') - ->from(Test::class, 't') + ->from(TestEntity::class, 't') ->orderBy('t.id', 'ASC'); $this->paginator = new DoctrinePaginator($this->queryBuilder); diff --git a/tests/Service/ConfigurationFactoryTest.php b/tests/Service/ConfigurationFactoryTest.php index 2fe7c0cd..a904c908 100644 --- a/tests/Service/ConfigurationFactoryTest.php +++ b/tests/Service/ConfigurationFactoryTest.php @@ -43,7 +43,7 @@ public function setUp(): void $this->serviceManager->setService('doctrine.cache.array', $this->getArrayCacheInstance()); $this->serviceManager->setService( 'doctrine.driver.orm_default', - $this->createMock(MappingDriver::class) + $this->createMock(MappingDriver::class), ); } @@ -227,7 +227,7 @@ public function testDefaultMetadatFactory(): void $ormConfig = $factory($this->serviceManager, Configuration::class); $this->assertEquals( ClassMetadataFactory::class, - $ormConfig->getClassMetadataFactoryName() + $ormConfig->getClassMetadataFactoryName(), ); } @@ -247,7 +247,7 @@ public function testWillInstantiateConfigWithoutEntityListenerResolverSetting(): $this->assertInstanceOf( EntityListenerResolver::class, - $ormConfig->getEntityListenerResolver() + $ormConfig->getEntityListenerResolver(), ); } diff --git a/tests/Service/DBALConnectionFactoryTest.php b/tests/Service/DBALConnectionFactoryTest.php index 7b1a6798..b9070e63 100644 --- a/tests/Service/DBALConnectionFactoryTest.php +++ b/tests/Service/DBALConnectionFactoryTest.php @@ -22,9 +22,7 @@ use function class_exists; -/** - * @covers \DoctrineORMModule\Service\DBALConnectionFactory - */ +/** @covers \DoctrineORMModule\Service\DBALConnectionFactory */ class DBALConnectionFactoryTest extends TestCase { protected ServiceManager $serviceManager; @@ -117,12 +115,12 @@ public function testDoctrineAddCustomCommentedType(): void $this->serviceManager->setService('Configuration', $config); $this->serviceManager->setService( 'doctrine.driver.orm_default', - $this->createMock(MappingDriver::class) + $this->createMock(MappingDriver::class), ); $configurationFactory = new ConfigurationFactory('orm_default'); $this->serviceManager->setService( 'doctrine.configuration.orm_default', - $configurationFactory($this->serviceManager, Configuration::class) + $configurationFactory($this->serviceManager, Configuration::class), ); $dbal = ($this->factory)($this->serviceManager, DBALConnection::class); $platform = $dbal->getDatabasePlatform(); diff --git a/tests/Service/MigrationsCommandFactoryTest.php b/tests/Service/MigrationsCommandFactoryTest.php index dd8bf6c4..7d12eea9 100644 --- a/tests/Service/MigrationsCommandFactoryTest.php +++ b/tests/Service/MigrationsCommandFactoryTest.php @@ -52,7 +52,7 @@ public function testExecuteFactory(): void { if (! class_exists(VersionCommand::class)) { $this->markTestIncomplete( - 'Migrations must be installed to run this test.' + 'Migrations must be installed to run this test.', ); } @@ -60,7 +60,7 @@ public function testExecuteFactory(): void $this->assertInstanceOf( ExecuteCommand::class, - $factory($this->serviceLocator, ExecuteCommand::class) + $factory($this->serviceLocator, ExecuteCommand::class), ); } @@ -68,7 +68,7 @@ public function testDiffFactory(): void { if (! class_exists(VersionCommand::class)) { $this->markTestIncomplete( - 'Migrations must be installed to run this test.' + 'Migrations must be installed to run this test.', ); } @@ -76,7 +76,7 @@ public function testDiffFactory(): void $this->assertInstanceOf( DiffCommand::class, - $factory($this->serviceLocator, DiffCommand::class) + $factory($this->serviceLocator, DiffCommand::class), ); } @@ -92,7 +92,7 @@ public function testDefineDependencyFactoryServicesFromConfig(): void { if (! class_exists(VersionCommand::class)) { $this->markTestIncomplete( - 'Migrations must be installed to run this test.' + 'Migrations must be installed to run this test.', ); } @@ -125,7 +125,7 @@ public function testNoDefineDependencyFactoryServicesFromConfig(): void { if (! class_exists(VersionCommand::class)) { $this->markTestIncomplete( - 'Migrations must be installed to run this test.' + 'Migrations must be installed to run this test.', ); } diff --git a/tests/Service/RunSqlCommandFactoryTest.php b/tests/Service/RunSqlCommandFactoryTest.php index 30741d19..a3b655e2 100644 --- a/tests/Service/RunSqlCommandFactoryTest.php +++ b/tests/Service/RunSqlCommandFactoryTest.php @@ -10,9 +10,7 @@ use Laminas\ServiceManager\ServiceManager; use PHPUnit\Framework\TestCase; -/** - * @covers \DoctrineORMModule\Service\RunSqlCommandFactory - */ +/** @covers \DoctrineORMModule\Service\RunSqlCommandFactory */ class RunSqlCommandFactoryTest extends TestCase { private ServiceManager $serviceLocator; @@ -28,7 +26,7 @@ public function testCreateCommand(): void $this->assertInstanceOf( RunSqlCommand::class, - $factory($this->serviceLocator, RunSqlCommand::class) + $factory($this->serviceLocator, RunSqlCommand::class), ); } } diff --git a/tests/Service/SQLLoggerCollectorFactoryTest.php b/tests/Service/SQLLoggerCollectorFactoryTest.php index f9e0ec29..5b7ff10f 100644 --- a/tests/Service/SQLLoggerCollectorFactoryTest.php +++ b/tests/Service/SQLLoggerCollectorFactoryTest.php @@ -23,6 +23,7 @@ class SQLLoggerCollectorFactoryTest extends TestCase public function setUp(): void { parent::setUp(); + $this->services = new ServiceManager(); $this->factory = new SQLLoggerCollectorFactory('orm_default'); } @@ -39,7 +40,7 @@ public function testCreateSQLLoggerCollector(): void 'orm_default' => [], ], ], - ] + ], ); $service = ($this->factory)($this->services, SQLLoggerCollector::class); $this->assertInstanceOf(SQLLoggerCollector::class, $service); @@ -58,7 +59,7 @@ public function testCreateSQLLoggerWithCustomConfiguration(): void 'orm_default' => ['configuration' => 'configuration_service_id'], ], ], - ] + ], ); ($this->factory)($this->services, SQLLoggerCollector::class); $this->assertInstanceOf(SQLLogger::class, $configuration->getSQLLogger()); @@ -89,7 +90,7 @@ public function testCreateSQLLoggerWithPreviousExistingLoggerChainsLoggers(): vo 'orm_default' => ['sql_logger' => 'custom_logger'], ], ], - ] + ], ); ($this->factory)($this->services, SQLLoggerCollector::class); $logger = $configuration->getSQLLogger(); @@ -111,7 +112,7 @@ public function testCreateSQLLoggerWithCustomLogger(): void 'orm_default' => ['sql_logger' => 'logger_service_id'], ], ], - ] + ], ); ($this->factory)($this->services, SQLLoggerCollector::class); $this->assertSame($logger, $configuration->getSQLLogger()); @@ -128,7 +129,7 @@ public function testCreateSQLLoggerWithCustomName(): void 'orm_default' => ['name' => 'test_collector_name'], ], ], - ] + ], ); $service = ($this->factory)($this->services, SQLLoggerCollector::class); assert($service instanceof SQLLoggerCollector); diff --git a/tests/ServiceManagerFactory.php b/tests/ServiceManagerFactory.php index cc11a9df..f23797e2 100644 --- a/tests/ServiceManagerFactory.php +++ b/tests/ServiceManagerFactory.php @@ -22,12 +22,12 @@ class ServiceManagerFactory * * @param mixed[]|null $configuration */ - public static function getServiceManager(?array $configuration = null): ServiceManager + public static function getServiceManager(array|null $configuration = null): ServiceManager { $configuration = $configuration ?: include __DIR__ . '/config.php'; $serviceManager = new ServiceManager(); $serviceManagerConfig = new ServiceManagerConfig( - $configuration['service_manager'] ?? [] + $configuration['service_manager'] ?? [], ); $serviceManagerConfig->configureServiceManager($serviceManager); $serviceManager->setService('ApplicationConfig', $configuration); diff --git a/tests/Yuml/MetadataGrapherTest.php b/tests/Yuml/MetadataGrapherTest.php index 64f98d48..ae6c433c 100644 --- a/tests/Yuml/MetadataGrapherTest.php +++ b/tests/Yuml/MetadataGrapherTest.php @@ -28,9 +28,7 @@ public function setUp(): void $this->grapher = new MetadataGrapher(); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawSimpleEntity(): void { $class = $this->createMock(ClassMetadata::class); @@ -41,9 +39,7 @@ public function testDrawSimpleEntity(): void $this->assertSame('[Simple.Entity]', $this->grapher->generateFromMetadata([$class])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawSimpleEntityWithFields(): void { $class = $this->createMock(ClassMetadata::class); @@ -54,16 +50,14 @@ public function testDrawSimpleEntityWithFields(): void $this->returnCallback( static function ($field) { return $field === 'a'; - } - ) + }, + ), ); $this->assertSame('[Simple.Entity|+a;b;c]', $this->grapher->generateFromMetadata([$class])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawOneToOneUniDirectionalAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -82,9 +76,7 @@ public function testDrawOneToOneUniDirectionalAssociation(): void $this->assertSame('[A]-b 1>[B]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawOneToOneBiDirectionalAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -107,9 +99,7 @@ public function testDrawOneToOneBiDirectionalAssociation(): void $this->assertSame('[A]<>a 1-b 1>[B]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawOneToOneBiDirectionalInverseAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -132,9 +122,7 @@ public function testDrawOneToOneBiDirectionalInverseAssociation(): void $this->assertSame('[A][B]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawOneToManyBiDirectionalAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -157,9 +145,7 @@ public function testDrawOneToManyBiDirectionalAssociation(): void $this->assertSame('[A]<>a 1-b *>[B]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawOneToManyBiDirectionalInverseAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -182,9 +168,7 @@ public function testDrawOneToManyBiDirectionalInverseAssociation(): void $this->assertSame('[A]<>a *-b 1>[B]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawManyToManyUniDirectionalAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -203,9 +187,7 @@ public function testDrawManyToManyUniDirectionalAssociation(): void $this->assertSame('[A]-b *>[B]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawManyToManyUniDirectionalInverseAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -224,9 +206,7 @@ public function testDrawManyToManyUniDirectionalInverseAssociation(): void $this->assertSame('[A],[B]-a *>[A]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawManyToManyBiDirectionalAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -249,9 +229,7 @@ public function testDrawManyToManyBiDirectionalAssociation(): void $this->assertSame('[A]<>a *-b *>[B]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawManyToManyBiDirectionalInverseAssociation(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -274,9 +252,7 @@ public function testDrawManyToManyBiDirectionalInverseAssociation(): void $this->assertSame('[A][B]', $this->grapher->generateFromMetadata([$class1, $class2])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawManyToManyAssociationWithoutKnownInverseSide(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -290,9 +266,7 @@ public function testDrawManyToManyAssociationWithoutKnownInverseSide(): void $this->assertSame('[A]<>-b *>[B]', $this->grapher->generateFromMetadata([$class1])); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawInheritance(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -307,13 +281,11 @@ public function testDrawInheritance(): void $this->assertSame( '[stdClass]^[' . str_replace('\\', '.', $child) . ']', - $this->grapher->generateFromMetadata([$class2, $class1]) + $this->grapher->generateFromMetadata([$class2, $class1]), ); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawInheritedFields(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -330,13 +302,11 @@ public function testDrawInheritedFields(): void $this->assertSame( '[stdClass|inherited]^[' . str_replace('\\', '.', $child) . '|field2]', - $this->grapher->generateFromMetadata([$class2, $class1]) + $this->grapher->generateFromMetadata([$class2, $class1]), ); } - /** - * @covers \DoctrineORMModule\Yuml\MetadataGrapher - */ + /** @covers \DoctrineORMModule\Yuml\MetadataGrapher */ public function testDrawInheritedAssociations(): void { $class1 = $this->createMock(ClassMetadata::class); @@ -361,8 +331,8 @@ public function testDrawInheritedAssociations(): void $this->returnCallback( static function ($assoc) { return strtoupper($assoc); - } - ) + }, + ), ); $class2->expects($this->any())->method('isAssociationInverseSide')->will($this->returnValue(false)); $class2->expects($this->any())->method('isCollectionValuedAssociation')->will($this->returnValue(true)); @@ -379,7 +349,7 @@ static function ($assoc) { $childName = str_replace('\\', '.', $child); $this->assertSame( '[stdClass]<>-a *>[A],[stdClass]^[' . $childName . '],[' . $childName . ']<>-b *>[B]', - $this->grapher->generateFromMetadata([$class1, $class2]) + $this->grapher->generateFromMetadata([$class1, $class2]), ); } @@ -391,11 +361,11 @@ public function testDrawMultipleClassRelatedBothBiAndMonoDirectional( ClassMetadata $class1, ClassMetadata $class2, ClassMetadata $class3, - string $expected + string $expected, ): void { $this->assertSame( $expected, - $this->grapher->generateFromMetadata([$class1, $class2, $class3]) + $this->grapher->generateFromMetadata([$class1, $class2, $class3]), ); } diff --git a/tests/Yuml/YumlControllerTest.php b/tests/Yuml/YumlControllerTest.php index 08e40101..4f7df7ed 100644 --- a/tests/Yuml/YumlControllerTest.php +++ b/tests/Yuml/YumlControllerTest.php @@ -22,11 +22,9 @@ class YumlControllerTest extends TestCase { protected YumlController $controller; - /** @var Client&MockObject */ - protected $httpClient; + protected Client&MockObject $httpClient; - /** @var PluginManager&MockObject */ - protected $pluginManager; + protected PluginManager&MockObject $pluginManager; /** * {@inheritDoc} @@ -43,9 +41,7 @@ public function setUp(): void $this->controller->setPluginManager($this->pluginManager); } - /** - * @covers \DoctrineORMModule\Yuml\YumlController::indexAction - */ + /** @covers \DoctrineORMModule\Yuml\YumlController::indexAction */ public function testIndexActionWillRedirectToYuml(): void { $response = $this->createMock(Response::class); @@ -68,9 +64,7 @@ public function testIndexActionWillRedirectToYuml(): void $this->assertSame($controllerResponse, $this->controller->indexAction()); } - /** - * @covers \DoctrineORMModule\Yuml\YumlController::indexAction - */ + /** @covers \DoctrineORMModule\Yuml\YumlController::indexAction */ public function testIndexActionWillFailOnMalformedResponse(): void { $response = $this->createMock(Response::class); diff --git a/tests/testing.config.php b/tests/testing.config.php index f275b126..c27e593d 100644 --- a/tests/testing.config.php +++ b/tests/testing.config.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Doctrine\DBAL\Driver\PDO\SQLite\Driver; +use Doctrine\DBAL\Driver\PDO\SQLite\Driver as SQLiteDriver; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use DoctrineModule\Service\EventManagerFactory; use DoctrineORMModule\Service\ConfigurationFactory; @@ -55,13 +55,13 @@ 'orm_default' => [ 'configuration' => 'orm_default', 'eventmanager' => 'orm_default', - 'driverClass' => Driver::class, + 'driverClass' => SQLiteDriver::class, 'params' => ['memory' => true], ], 'orm_other' => [ 'configuration' => 'orm_other', 'eventmanager' => 'orm_other', - 'driverClass' => Driver::class, + 'driverClass' => SQLiteDriver::class, 'params' => ['memory' => true], ], ],