Skip to content

Commit

Permalink
Merge pull request #407 from doctrine/3.4.x
Browse files Browse the repository at this point in the history
Merge 3.4.x up into 4.0.x
  • Loading branch information
greg0ire authored Nov 11, 2023
2 parents d2c8c09 + 5988484 commit 26e5b40
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 41 deletions.
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 @@ -25,6 +25,7 @@ jobs:
php-version:
- "8.1"
- "8.2"
- "8.3"
dependencies:
- "highest"
stability:
Expand All @@ -34,11 +35,11 @@ jobs:
php-version: "8.1"
- 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 @@ -80,12 +81,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 @@ -40,9 +40,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 @@ -498,8 +498,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": "^5.4|^6.0|^7.0"
},
"require-dev": {
"doctrine/coding-standard": "^9",
"doctrine/coding-standard": "^9 || ^12",
"phpstan/phpstan": "^1.4.10",
"phpunit/phpunit": "^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

0 comments on commit 26e5b40

Please sign in to comment.