Skip to content

Commit

Permalink
Merge pull request #451 from greg0ire/4.0.x
Browse files Browse the repository at this point in the history
Merge 3.6.x up into 4.0.x
  • Loading branch information
greg0ire authored Nov 4, 2024
2 parents a345e6c + 431d2b1 commit 4add114
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 157 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
Expand All @@ -34,7 +32,7 @@ jobs:
- "stable"
include:
- dependencies: "lowest"
php-version: "7.4"
php-version: "8.1"
- dependencies: "highest"
stability: "dev"
php-version: "8.3"
Expand Down Expand Up @@ -71,18 +69,10 @@ jobs:

- name: "Upload coverage file"
uses: "actions/upload-artifact@v4"
if: "${{ ! contains(matrix.extra_constraint, '/') }}"
with:
name: "phpunit-${{ matrix.dependencies }}-${{ matrix.stability }}-${{ matrix.php-version }}.coverage"
path: "coverage.xml"

- name: "Upload coverage file, sanitize the name"
uses: "actions/upload-artifact@v4"
if: "${{ contains(matrix.extra_constraint, '/') }}"
with:
name: "phpunit-symfony-lts-${{ matrix.php-version }}.coverage"
path: "coverage.xml"

upload_coverage:
name: "Upload coverage to Codecov"
runs-on: "ubuntu-22.04"
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"doctrine/data-fixtures": "^1.3",
"doctrine/doctrine-bundle": "^2.2",
"doctrine/orm": "^2.14.0 || ^3.0",
Expand Down
7 changes: 2 additions & 5 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>

<config name="php_version" value="70400"/>
<config name="php_version" value="80100"/>

<!-- Ignore warnings and show progress of the run -->
<arg value="nps"/>

<file>src</file>
<file>tests</file>

<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
</rule>
<rule ref="Doctrine" />


<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming.SuperfluousSuffix">
Expand Down
24 changes: 0 additions & 24 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
parameters:
excludePaths:
# Contains an error that is impossible to ignore
- tests/IntegrationTest.php

ignoreErrors:
-
message: "#^Call to an undefined method Doctrine\\\\Bundle\\\\FixturesBundle\\\\Loader\\\\SymfonyFixturesLoader\\:\\:getFixture\\(\\)\\.$#"
count: 1
path: src/Loader/SymfonyFixturesLoader.php

-
message: "#^Call to an undefined static method Doctrine\\\\Bundle\\\\FixturesBundle\\\\Loader\\\\SymfonyBridgeLoader\\:\\:addFixture\\(\\)\\.$#"
count: 1
path: src/Loader/SymfonyFixturesLoader.php

-
message: "#^Call to an undefined static method Doctrine\\\\Bundle\\\\FixturesBundle\\\\Loader\\\\SymfonyBridgeLoader\\:\\:getFixtures\\(\\)\\.$#"
count: 1
path: src/Loader/SymfonyFixturesLoader.php

-
message: "#^Class Doctrine\\\\Bundle\\\\FixturesBundle\\\\Loader\\\\SymfonyFixturesLoader does not have a constructor and must be instantiated without any parameters\\.$#"
count: 2
path: tests/Command/LoadDataFixturesDoctrineCommandTest.php

-
message: "#^Constructor of class Doctrine\\\\Bundle\\\\FixturesBundle\\\\Tests\\\\Fixtures\\\\FooBundle\\\\DataFixtures\\\\RequiredConstructorArgsFixtures has an unused parameter \\$fooRequiredArg\\.$#"
count: 1
Expand Down
9 changes: 0 additions & 9 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,4 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<DuplicateClass>
<errorLevel type="suppress">
<file name="src/Command/CommandCompatibility.php"/>
<file name="tests/IntegrationTest.php"/>
</errorLevel>
</DuplicateClass>
</issueHandlers>
</psalm>
35 changes: 0 additions & 35 deletions src/Command/CommandCompatibility.php

This file was deleted.

22 changes: 7 additions & 15 deletions src/Command/LoadDataFixturesDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@
*/
class LoadDataFixturesDoctrineCommand extends DoctrineCommand
{
use CommandCompatibility;

private SymfonyFixturesLoader $fixturesLoader;

/** @var PurgerFactory[] */
private array $purgerFactories;

/** @param PurgerFactory[] $purgerFactories */
public function __construct(SymfonyFixturesLoader $fixturesLoader, ?ManagerRegistry $doctrine = null, array $purgerFactories = [])
{
public function __construct(
private SymfonyFixturesLoader $fixturesLoader,
ManagerRegistry|null $doctrine = null,
private array $purgerFactories = [],
) {
if ($doctrine === null) {
trigger_deprecation(
'doctrine/fixtures-bundle',
Expand All @@ -48,13 +44,9 @@ public function __construct(SymfonyFixturesLoader $fixturesLoader, ?ManagerRegis
}

parent::__construct($doctrine);

$this->fixturesLoader = $fixturesLoader;
$this->purgerFactories = $purgerFactories;
}

/** @return void */
protected function configure()
protected function configure(): void
{
$this
->setName('doctrine:fixtures:load')
Expand Down Expand Up @@ -88,7 +80,7 @@ protected function configure()
EOT);
}

private function doExecute(InputInterface $input, OutputInterface $output): int
protected function execute(InputInterface $input, OutputInterface $output): int
{
$ui = new SymfonyStyle($input, $output);

Expand Down
4 changes: 1 addition & 3 deletions src/DependencyInjection/DoctrineFixturesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ class DoctrineFixturesExtension extends Extension
{
/**
* {@inheritDoc}
*
* @return void
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__) . '/../config'));

Expand Down
3 changes: 1 addition & 2 deletions src/DoctrineFixturesBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

class DoctrineFixturesBundle extends Bundle
{
/** @return void */
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new FixturesCompilerPass());
$container->addCompilerPass(new PurgerFactoryCompilerPass());
Expand Down
22 changes: 0 additions & 22 deletions src/Loader/SymfonyBridgeLoader.php

This file was deleted.

7 changes: 4 additions & 3 deletions src/Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\Loader;
use LogicException;
use ReflectionClass;

Expand All @@ -16,7 +17,7 @@
use function get_class;
use function sprintf;

final class SymfonyFixturesLoader extends SymfonyBridgeLoader
final class SymfonyFixturesLoader extends Loader
{
/** @var FixtureInterface[] */
private array $loadedFixtures = [];
Expand Down Expand Up @@ -48,7 +49,7 @@ public function addFixtures(array $fixtures): void

public function addFixture(FixtureInterface $fixture): void
{
$class = get_class($fixture);
$class = $fixture::class;
$this->loadedFixtures[$class] = $fixture;

$reflection = new ReflectionClass($fixture);
Expand Down Expand Up @@ -109,7 +110,7 @@ public function getFixtures(array $groups = []): array

$filteredFixtures = [];
foreach ($fixtures as $order => $fixture) {
$fixtureClass = get_class($fixture);
$fixtureClass = $fixture::class;
if (isset($requiredFixtures[$fixtureClass])) {
$filteredFixtures[$order] = $fixture;
continue;
Expand Down
7 changes: 3 additions & 4 deletions src/Purger/ORMPurgerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Doctrine\Bundle\FixturesBundle\Purger;

use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\Common\DataFixtures\Purger\PurgerInterface;
use Doctrine\ORM\EntityManagerInterface;

final class ORMPurgerFactory implements PurgerFactory
Expand All @@ -14,11 +13,11 @@ final class ORMPurgerFactory implements PurgerFactory
* {@inheritDoc}
*/
public function createForEntityManager(
?string $emName,
string|null $emName,
EntityManagerInterface $em,
array $excluded = [],
bool $purgeWithTruncate = false
): PurgerInterface {
bool $purgeWithTruncate = false,
): ORMPurger {
$purger = new ORMPurger($em, $excluded);
$purger->setPurgeMode($purgeWithTruncate ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);

Expand Down
4 changes: 2 additions & 2 deletions src/Purger/PurgerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ interface PurgerFactory
{
/** @psalm-param list<string> $excluded */
public function createForEntityManager(
?string $emName,
string|null $emName,
EntityManagerInterface $em,
array $excluded = [],
bool $purgeWithTruncate = false
bool $purgeWithTruncate = false,
): PurgerInterface;
}
5 changes: 2 additions & 3 deletions tests/Command/LoadDataFixturesDoctrineCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\DependencyInjection\Container;
use TypeError;

use function sprintf;
Expand All @@ -24,7 +23,7 @@ class LoadDataFixturesDoctrineCommandTest extends TestCase
/** @group legacy */
public function testInstantiatingWithoutManagerRegistry(): void
{
$loader = new SymfonyFixturesLoader(new Container());
$loader = new SymfonyFixturesLoader();

$this->expectDeprecation('Since doctrine/fixtures-bundle 3.2: Argument 2 of Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand::__construct() expects an instance of Doctrine\Persistence\ManagerRegistry, not passing it will throw a \TypeError in DoctrineFixturesBundle 4.0.');

Expand All @@ -47,7 +46,7 @@ public function testInstantiatingWithoutManagerRegistry(): void
public function testInstantiatingWithManagerRegistry(): void
{
$registry = $this->createMock(ManagerRegistry::class);
$loader = new SymfonyFixturesLoader(new Container());
$loader = new SymfonyFixturesLoader();

new LoadDataFixturesDoctrineCommand($loader, $registry);
}
Expand Down
Loading

0 comments on commit 4add114

Please sign in to comment.