From 121bbeb3a8e09d72256a27e49860bd7e17891d14 Mon Sep 17 00:00:00 2001 From: LucileDT Date: Mon, 15 May 2023 17:46:51 +0200 Subject: [PATCH 1/7] Add code example for purge exclusion (#389) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégoire Paris --- Resources/doc/index.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index ebbab61..3b7683c 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -302,7 +302,11 @@ By default all previously existing data is purged using ``DELETE FROM table`` st If you want to exclude a set of tables from being purged, e.g. because your schema comes with pre-populated, semi-static data, pass the option ``--purge-exclusions``. Specify ``--purge-exclusions`` multiple times to exclude -multiple tables. +multiple tables: + +.. code-block:: terminal + + $ php bin/console doctrine:fixtures:load --purge-exclusions=post_category --purge-exclusions=comment_type You can also customize purging behavior significantly more and implement a custom purger plus a custom purger factory:: From 3f8e63d0551569d301fab7ba3993c974f3ada7f4 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Tue, 23 May 2023 13:13:05 +0200 Subject: [PATCH 2/7] Add a note that object references only work for Entities --- Resources/doc/index.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 3b7683c..3eb5519 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -152,7 +152,11 @@ Sharing Objects between Fixtures When using multiple fixtures files, you can reuse PHP objects across different files thanks to the **object references**. Use the ``addReference()`` method to give a name to any object and then, use the ``getReference()`` method to get the -exact same object via its name: +exact same object via its name. + +.. note:: + + Adding object references only works for ORM entities or ODM documents. .. code-block:: php From b8d9290be81e87d16fad228a3e732935efb1c295 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Jun 2023 16:48:28 +0200 Subject: [PATCH 3/7] [Doc] Fix a minor doc syntax issue --- Resources/doc/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 3eb5519..8e51d3e 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -429,6 +429,6 @@ Then, enable Dependency Injection for the ``fixtures`` directory: .. caution:: This will not override the default ``src/DataFixtures`` directory when creating fixtures with the - `Symfony MakerBundle` (``make:fixtures``). + `Symfony MakerBundle`_ (``make:fixtures``). .. _`Symfony MakerBundle`: https://symfony.com/bundles/SymfonyMakerBundle/current/index.html From 88daa7a42e3d6358df8cc894ba7128a67f8755f0 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 29 Jul 2023 18:23:06 +0200 Subject: [PATCH 4/7] Add static analysis files to .gitattributes --- .gitattributes | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitattributes b/.gitattributes index 1059327..e19c583 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,7 @@ /Tests export-ignore /phpcs.xml.dist export-ignore /phpunit.xml.dist export-ignore +/phpstan.neon.dist export-ignore +/phpstan-baseline.neon export-ignore +/psalm.xml export-ignore +/psalm-baseline.xml export-ignore From b152d7e6e050a30e90149faeef3cf86c136d99ec Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 28 Oct 2023 22:35:32 +0200 Subject: [PATCH 5/7] CI: Bump workflows (#405) --- .github/workflows/coding-standards.yml | 2 +- .github/workflows/continuous-integration.yml | 9 +++++---- .github/workflows/release-on-milestone-closed.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- psalm.xml | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index f076586..4c3441a 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -12,4 +12,4 @@ on: jobs: coding-standards: name: "Coding Standards" - uses: "doctrine/.github/.github/workflows/coding-standards.yml@3.0.0" + uses: "doctrine/.github/.github/workflows/coding-standards.yml@3.1.0" diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 3567622..08bd606 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -30,6 +30,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" dependencies: - "highest" stability: @@ -47,11 +48,11 @@ jobs: php-version: "7.3" - dependencies: "highest" stability: "dev" - php-version: "8.2" + php-version: "8.3" steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" with: fetch-depth: 2 @@ -114,12 +115,12 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v3" + uses: "actions/checkout@v4" with: fetch-depth: 2 - name: "Download coverage files" - uses: "actions/download-artifact@v2" + uses: "actions/download-artifact@v3" with: path: "reports" diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml index 44c68ff..cc6ac55 100644 --- a/.github/workflows/release-on-milestone-closed.yml +++ b/.github/workflows/release-on-milestone-closed.yml @@ -8,7 +8,7 @@ on: jobs: release: name: "Git tag, release & create merge-up PR" - uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@3.0.0" + uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@3.1.0" secrets: GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }} GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 8bccabc..e8e4dc1 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -11,4 +11,4 @@ on: jobs: static-analysis: - uses: "doctrine/.github/.github/workflows/static-analysis.yml@3.0.0" + uses: "doctrine/.github/.github/workflows/static-analysis.yml@3.1.0" diff --git a/psalm.xml b/psalm.xml index d54587e..71859f3 100644 --- a/psalm.xml +++ b/psalm.xml @@ -6,7 +6,7 @@ xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml" - phpVersion="8.1" + phpVersion="8.2" > From 61976343213e323b2034f256d13ede29a3c0f88f Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 28 Oct 2023 22:36:17 +0200 Subject: [PATCH 6/7] Doctrine CS 12 (#404) --- Command/LoadDataFixturesDoctrineCommand.php | 10 +++------- DependencyInjection/DoctrineFixturesExtension.php | 2 +- Purger/PurgerFactory.php | 4 +--- Tests/Command/LoadDataFixturesDoctrineCommandTest.php | 4 +--- Tests/IntegrationTest.php | 4 +--- composer.json | 2 +- 6 files changed, 8 insertions(+), 18 deletions(-) diff --git a/Command/LoadDataFixturesDoctrineCommand.php b/Command/LoadDataFixturesDoctrineCommand.php index c6cb30d..ce277d2 100644 --- a/Command/LoadDataFixturesDoctrineCommand.php +++ b/Command/LoadDataFixturesDoctrineCommand.php @@ -37,9 +37,7 @@ class LoadDataFixturesDoctrineCommand extends DoctrineCommand /** @var PurgerFactory[] */ private $purgerFactories; - /** - * @param PurgerFactory[] $purgerFactories - */ + /** @param PurgerFactory[] $purgerFactories */ public function __construct(SymfonyFixturesLoader $fixturesLoader, ?ManagerRegistry $doctrine = null, array $purgerFactories = []) { if ($doctrine === null) { @@ -69,7 +67,7 @@ protected function configure() ->addOption('purge-exclusions', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'List of database tables to ignore while purging') ->addOption('shard', null, InputOption::VALUE_REQUIRED, 'The shard connection to use for this command.') ->addOption('purge-with-truncate', null, InputOption::VALUE_NONE, 'Purge data by using a database-level TRUNCATE statement') - ->setHelp(<<setHelp(<<<'EOT' The %command.name% command loads data fixtures from your application: php %command.full_name% @@ -93,9 +91,7 @@ protected function configure() ); } - /** - * @return int - */ + /** @return int */ protected function execute(InputInterface $input, OutputInterface $output) { $ui = new SymfonyStyle($input, $output); diff --git a/DependencyInjection/DoctrineFixturesExtension.php b/DependencyInjection/DoctrineFixturesExtension.php index 36680ab..e23e40b 100644 --- a/DependencyInjection/DoctrineFixturesExtension.php +++ b/DependencyInjection/DoctrineFixturesExtension.php @@ -16,7 +16,7 @@ class DoctrineFixturesExtension extends Extension { /** - * {@inheritdoc} + * {@inheritDoc} * * @return void */ diff --git a/Purger/PurgerFactory.php b/Purger/PurgerFactory.php index 1effb1f..b625888 100644 --- a/Purger/PurgerFactory.php +++ b/Purger/PurgerFactory.php @@ -9,9 +9,7 @@ interface PurgerFactory { - /** - * @psalm-param list $excluded - */ + /** @psalm-param list $excluded */ public function createForEntityManager( ?string $emName, EntityManagerInterface $em, diff --git a/Tests/Command/LoadDataFixturesDoctrineCommandTest.php b/Tests/Command/LoadDataFixturesDoctrineCommandTest.php index 6607ce9..987e355 100644 --- a/Tests/Command/LoadDataFixturesDoctrineCommandTest.php +++ b/Tests/Command/LoadDataFixturesDoctrineCommandTest.php @@ -41,9 +41,7 @@ public function testInstantiatingWithoutManagerRegistry(): void } } - /** - * @doesNotPerformAssertions - */ + /** @doesNotPerformAssertions */ public function testInstantiatingWithManagerRegistry(): void { $registry = $this->createMock(ManagerRegistry::class); diff --git a/Tests/IntegrationTest.php b/Tests/IntegrationTest.php index 963a127..6a9d226 100644 --- a/Tests/IntegrationTest.php +++ b/Tests/IntegrationTest.php @@ -499,8 +499,6 @@ public function testRunCommandWithPurgeMode(): void interface ForwardCompatibleEntityManager extends EntityManagerInterface { - /** - * @return mixed - */ + /** @return mixed */ public function wrapInTransaction(callable $func); } diff --git a/composer.json b/composer.json index 62050f7..7ee1e88 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "symfony/http-kernel": "^3.4|^4.3|^5.0|^6.0" }, "require-dev": { - "doctrine/coding-standard": "^9", + "doctrine/coding-standard": "^9 || ^12", "phpstan/phpstan": "^1.4.10", "phpunit/phpunit": "^7.5.20 || ^8.5.26 || ^9.5.20", "symfony/phpunit-bridge": "^6.0.8", From 5988484f79362cd7d06564bd11be7ce622e08c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Freerich=20B=C3=A4thge?= Date: Sun, 29 Oct 2023 19:36:06 +0100 Subject: [PATCH 7/7] Add documentation for yaml service configuration (#393) * Add yaml service configuration * Update index.rst --- Resources/doc/index.rst | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 8e51d3e..0741d6c 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -406,25 +406,38 @@ First, add a new ``PSR-4`` autoload-entry in the ``composer.json`` with the new "autoload-dev": { "psr-4": { "...": "...", - "DataFixtures\\": "fixtures" + "DataFixtures\\": "fixtures/" } }, -Then, enable Dependency Injection for the ``fixtures`` directory: +.. note:: -.. code-block:: php + You need to dump the autoloader with ``composer dump-autoloader`` - // config/services.php - namespace Symfony\Component\DependencyInjection\Loader\Configurator; +Then, enable Dependency Injection for the ``fixtures`` directory: - return function(ContainerConfigurator $container) : void { - $services = $container->services() - ->defaults() - ->autowire() - ->autoconfigure(); +.. configuration-block:: - $services->load('DataFixtures\\', '../fixtures'); - }; + .. code-block:: yaml + + # config/services.yaml + services: + DataFixtures\: + resource: '../fixtures' + + .. code-block:: php + + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return function(ContainerConfigurator $container) : void { + $services = $container->services() + ->defaults() + ->autowire() + ->autoconfigure(); + + $services->load('DataFixtures\\', '../fixtures'); + }; .. caution::