Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 3.4.x up into 4.0.x #407

Merged
merged 10 commits into from
Nov 11, 2023
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 5 additions & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "highest"
stability:
Expand All @@ -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

Expand Down Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 3 additions & 7 deletions Command/LoadDataFixturesDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(<<<EOT
->setHelp(<<<'EOT'
The <info>%command.name%</info> command loads data fixtures from your application:

<info>php %command.full_name%</info>
Expand All @@ -93,9 +91,7 @@ protected function configure()
);
}

/**
* @return int
*/
/** @return int */
protected function execute(InputInterface $input, OutputInterface $output)
{
$ui = new SymfonyStyle($input, $output);
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/DoctrineFixturesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class DoctrineFixturesExtension extends Extension
{
/**
* {@inheritdoc}
* {@inheritDoc}
*
* @return void
*/
Expand Down
4 changes: 1 addition & 3 deletions Purger/PurgerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@

interface PurgerFactory
{
/**
* @psalm-param list<string> $excluded
*/
/** @psalm-param list<string> $excluded */
public function createForEntityManager(
?string $emName,
EntityManagerInterface $em,
Expand Down
51 changes: 36 additions & 15 deletions Resources/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -302,7 +306,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::

Expand Down Expand Up @@ -398,29 +406,42 @@ 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::

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
4 changes: 1 addition & 3 deletions Tests/Command/LoadDataFixturesDoctrineCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public function testInstantiatingWithoutManagerRegistry(): void
}
}

/**
* @doesNotPerformAssertions
*/
/** @doesNotPerformAssertions */
public function testInstantiatingWithManagerRegistry(): void
{
$registry = $this->createMock(ManagerRegistry::class);
Expand Down
4 changes: 1 addition & 3 deletions Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,6 @@ public function testRunCommandWithPurgeMode(): void

interface ForwardCompatibleEntityManager extends EntityManagerInterface
{
/**
* @return mixed
*/
/** @return mixed */
public function wrapInTransaction(callable $func);
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<projectFiles>
<directory name="Command" />
Expand Down