From 134bd7e1e25fb7253e5d677ecb0ffa70d493fa5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 29 Mar 2024 08:36:43 +0100 Subject: [PATCH] Switch to a modern directory structure Here are the steps I followed: - `mkdir src` - `git mv *.php src` - `git mv Command/ DependencyInjection Loader Purger src` - adjust autoloading path - overrode `Bunde::getPath()` - `git mv Resources/doc/ docs` - `git mv Resources/config/ config` - `git mv Tests/ tests` --- .gitattributes | 2 +- composer.json | 5 ++++- {Resources/config => config}/services.xml | 0 {Resources/doc => docs}/index.rst | 0 phpcs.xml.dist | 16 ++++++++-------- phpstan-baseline.neon | 11 +++++------ phpstan.neon.dist | 5 ++--- phpunit.xml.dist | 9 ++------- psalm.xml | 15 ++++----------- .../Command}/CommandCompatibility.php | 0 .../Command}/LoadDataFixturesDoctrineCommand.php | 0 .../CompilerPass/FixturesCompilerPass.php | 0 .../CompilerPass/PurgerFactoryCompilerPass.php | 0 .../DoctrineFixturesExtension.php | 2 +- .../DoctrineFixturesBundle.php | 7 +++++++ Fixture.php => src/Fixture.php | 0 .../FixtureGroupInterface.php | 0 {Loader => src/Loader}/SymfonyBridgeLoader.php | 0 {Loader => src/Loader}/SymfonyFixturesLoader.php | 0 .../ORMFixtureInterface.php | 0 {Purger => src/Purger}/ORMPurgerFactory.php | 0 {Purger => src/Purger}/PurgerFactory.php | 0 .../LoadDataFixturesDoctrineCommandTest.php | 0 ...ependentOnRequiredConstructorArgsFixtures.php | 0 .../FooBundle/DataFixtures/OtherFixtures.php | 0 .../RequiredConstructorArgsFixtures.php | 0 .../DataFixtures/WithDependenciesFixtures.php | 0 .../Fixtures/FooBundle/FooBundle.php | 0 {Tests => tests}/IntegrationTest.php | 0 {Tests => tests}/IntegrationTestKernel.php | 0 {Tests => tests}/Purger/ORMPurgerFactoryTest.php | 0 31 files changed, 34 insertions(+), 38 deletions(-) rename {Resources/config => config}/services.xml (100%) rename {Resources/doc => docs}/index.rst (100%) rename {Command => src/Command}/CommandCompatibility.php (100%) rename {Command => src/Command}/LoadDataFixturesDoctrineCommand.php (100%) rename {DependencyInjection => src/DependencyInjection}/CompilerPass/FixturesCompilerPass.php (100%) rename {DependencyInjection => src/DependencyInjection}/CompilerPass/PurgerFactoryCompilerPass.php (100%) rename {DependencyInjection => src/DependencyInjection}/DoctrineFixturesExtension.php (95%) rename DoctrineFixturesBundle.php => src/DoctrineFixturesBundle.php (85%) rename Fixture.php => src/Fixture.php (100%) rename FixtureGroupInterface.php => src/FixtureGroupInterface.php (100%) rename {Loader => src/Loader}/SymfonyBridgeLoader.php (100%) rename {Loader => src/Loader}/SymfonyFixturesLoader.php (100%) rename ORMFixtureInterface.php => src/ORMFixtureInterface.php (100%) rename {Purger => src/Purger}/ORMPurgerFactory.php (100%) rename {Purger => src/Purger}/PurgerFactory.php (100%) rename {Tests => tests}/Command/LoadDataFixturesDoctrineCommandTest.php (100%) rename {Tests => tests}/Fixtures/FooBundle/DataFixtures/DependentOnRequiredConstructorArgsFixtures.php (100%) rename {Tests => tests}/Fixtures/FooBundle/DataFixtures/OtherFixtures.php (100%) rename {Tests => tests}/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php (100%) rename {Tests => tests}/Fixtures/FooBundle/DataFixtures/WithDependenciesFixtures.php (100%) rename {Tests => tests}/Fixtures/FooBundle/FooBundle.php (100%) rename {Tests => tests}/IntegrationTest.php (100%) rename {Tests => tests}/IntegrationTestKernel.php (100%) rename {Tests => tests}/Purger/ORMPurgerFactoryTest.php (100%) diff --git a/.gitattributes b/.gitattributes index e19c583f..fc0636b9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ /.gitattributes export-ignore /.github export-ignore /.gitignore export-ignore -/Tests export-ignore +/tests export-ignore /phpcs.xml.dist export-ignore /phpunit.xml.dist export-ignore /phpstan.neon.dist export-ignore diff --git a/composer.json b/composer.json index 672163c1..2fe882e3 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,10 @@ "doctrine/dbal": "< 3" }, "autoload": { - "psr-4": { "Doctrine\\Bundle\\FixturesBundle\\": "" } + "psr-4": { "Doctrine\\Bundle\\FixturesBundle\\": "src" } + }, + "autoload-dev": { + "psr-4": { "Doctrine\\Bundle\\FixturesBundle\\Tests\\": "tests" } }, "config": { "sort-packages": true, diff --git a/Resources/config/services.xml b/config/services.xml similarity index 100% rename from Resources/config/services.xml rename to config/services.xml diff --git a/Resources/doc/index.rst b/docs/index.rst similarity index 100% rename from Resources/doc/index.rst rename to docs/index.rst diff --git a/phpcs.xml.dist b/phpcs.xml.dist index ded24308..3c99fb93 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -11,8 +11,8 @@ - . - /vendor + src + tests @@ -21,15 +21,15 @@ - FixtureGroupInterface.php - ORMFixtureInterface.php + src/FixtureGroupInterface.php + src/ORMFixtureInterface.php - Loader/SymfonyBridgeLoader.php - Command/CommandCompatibility.php - Tests/IntegrationTest.php + src/Loader/SymfonyBridgeLoader.php + src/Command/CommandCompatibility.php + tests/IntegrationTest.php - Tests/IntegrationTest.php + tests/IntegrationTest.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 72cb0bd2..6d42deef 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,26 +1,25 @@ parameters: excludePaths: # Contains an error that is impossible to ignore - - Tests/IntegrationTest.php + - tests/IntegrationTest.php ignoreErrors: - message: "#^Call to an undefined static method Doctrine\\\\Bundle\\\\FixturesBundle\\\\Loader\\\\SymfonyBridgeLoader\\:\\:addFixture\\(\\)\\.$#" count: 1 - path: Loader/SymfonyFixturesLoader.php + path: src/Loader/SymfonyFixturesLoader.php - message: "#^Call to an undefined static method Doctrine\\\\Bundle\\\\FixturesBundle\\\\Loader\\\\SymfonyBridgeLoader\\:\\:getFixtures\\(\\)\\.$#" count: 1 - path: Loader/SymfonyFixturesLoader.php + 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 + path: tests/Command/LoadDataFixturesDoctrineCommandTest.php - message: "#^Constructor of class Doctrine\\\\Bundle\\\\FixturesBundle\\\\Tests\\\\Fixtures\\\\FooBundle\\\\DataFixtures\\\\RequiredConstructorArgsFixtures has an unused parameter \\$fooRequiredArg\\.$#" count: 1 - path: Tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php - + path: tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 5a7126fa..ff487480 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -2,9 +2,8 @@ parameters: phpVersion: 80100 level: 3 paths: - - . - excludePaths: - - vendor + - src + - tests includes: - phpstan-baseline.neon diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 184845f4..0389eb53 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,18 +3,13 @@ - ./Tests + ./tests - . - - ./Resources - ./Tests - ./vendor - + src diff --git a/psalm.xml b/psalm.xml index 148409fa..0d646354 100644 --- a/psalm.xml +++ b/psalm.xml @@ -10,15 +10,8 @@ findUnusedCode="false" > - - - - - - - - - + + @@ -27,8 +20,8 @@ - - + + diff --git a/Command/CommandCompatibility.php b/src/Command/CommandCompatibility.php similarity index 100% rename from Command/CommandCompatibility.php rename to src/Command/CommandCompatibility.php diff --git a/Command/LoadDataFixturesDoctrineCommand.php b/src/Command/LoadDataFixturesDoctrineCommand.php similarity index 100% rename from Command/LoadDataFixturesDoctrineCommand.php rename to src/Command/LoadDataFixturesDoctrineCommand.php diff --git a/DependencyInjection/CompilerPass/FixturesCompilerPass.php b/src/DependencyInjection/CompilerPass/FixturesCompilerPass.php similarity index 100% rename from DependencyInjection/CompilerPass/FixturesCompilerPass.php rename to src/DependencyInjection/CompilerPass/FixturesCompilerPass.php diff --git a/DependencyInjection/CompilerPass/PurgerFactoryCompilerPass.php b/src/DependencyInjection/CompilerPass/PurgerFactoryCompilerPass.php similarity index 100% rename from DependencyInjection/CompilerPass/PurgerFactoryCompilerPass.php rename to src/DependencyInjection/CompilerPass/PurgerFactoryCompilerPass.php diff --git a/DependencyInjection/DoctrineFixturesExtension.php b/src/DependencyInjection/DoctrineFixturesExtension.php similarity index 95% rename from DependencyInjection/DoctrineFixturesExtension.php rename to src/DependencyInjection/DoctrineFixturesExtension.php index e23e40bf..f66873e5 100644 --- a/DependencyInjection/DoctrineFixturesExtension.php +++ b/src/DependencyInjection/DoctrineFixturesExtension.php @@ -22,7 +22,7 @@ class DoctrineFixturesExtension extends Extension */ public function load(array $configs, ContainerBuilder $container) { - $loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__) . '/Resources/config')); + $loader = new XmlFileLoader($container, new FileLocator(dirname(__DIR__) . '/../config')); $loader->load('services.xml'); diff --git a/DoctrineFixturesBundle.php b/src/DoctrineFixturesBundle.php similarity index 85% rename from DoctrineFixturesBundle.php rename to src/DoctrineFixturesBundle.php index 50532722..67c2e743 100644 --- a/DoctrineFixturesBundle.php +++ b/src/DoctrineFixturesBundle.php @@ -9,6 +9,8 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; +use function dirname; + class DoctrineFixturesBundle extends Bundle { /** @return void */ @@ -17,4 +19,9 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new FixturesCompilerPass()); $container->addCompilerPass(new PurgerFactoryCompilerPass()); } + + public function getPath(): string + { + return dirname(__DIR__); + } } diff --git a/Fixture.php b/src/Fixture.php similarity index 100% rename from Fixture.php rename to src/Fixture.php diff --git a/FixtureGroupInterface.php b/src/FixtureGroupInterface.php similarity index 100% rename from FixtureGroupInterface.php rename to src/FixtureGroupInterface.php diff --git a/Loader/SymfonyBridgeLoader.php b/src/Loader/SymfonyBridgeLoader.php similarity index 100% rename from Loader/SymfonyBridgeLoader.php rename to src/Loader/SymfonyBridgeLoader.php diff --git a/Loader/SymfonyFixturesLoader.php b/src/Loader/SymfonyFixturesLoader.php similarity index 100% rename from Loader/SymfonyFixturesLoader.php rename to src/Loader/SymfonyFixturesLoader.php diff --git a/ORMFixtureInterface.php b/src/ORMFixtureInterface.php similarity index 100% rename from ORMFixtureInterface.php rename to src/ORMFixtureInterface.php diff --git a/Purger/ORMPurgerFactory.php b/src/Purger/ORMPurgerFactory.php similarity index 100% rename from Purger/ORMPurgerFactory.php rename to src/Purger/ORMPurgerFactory.php diff --git a/Purger/PurgerFactory.php b/src/Purger/PurgerFactory.php similarity index 100% rename from Purger/PurgerFactory.php rename to src/Purger/PurgerFactory.php diff --git a/Tests/Command/LoadDataFixturesDoctrineCommandTest.php b/tests/Command/LoadDataFixturesDoctrineCommandTest.php similarity index 100% rename from Tests/Command/LoadDataFixturesDoctrineCommandTest.php rename to tests/Command/LoadDataFixturesDoctrineCommandTest.php diff --git a/Tests/Fixtures/FooBundle/DataFixtures/DependentOnRequiredConstructorArgsFixtures.php b/tests/Fixtures/FooBundle/DataFixtures/DependentOnRequiredConstructorArgsFixtures.php similarity index 100% rename from Tests/Fixtures/FooBundle/DataFixtures/DependentOnRequiredConstructorArgsFixtures.php rename to tests/Fixtures/FooBundle/DataFixtures/DependentOnRequiredConstructorArgsFixtures.php diff --git a/Tests/Fixtures/FooBundle/DataFixtures/OtherFixtures.php b/tests/Fixtures/FooBundle/DataFixtures/OtherFixtures.php similarity index 100% rename from Tests/Fixtures/FooBundle/DataFixtures/OtherFixtures.php rename to tests/Fixtures/FooBundle/DataFixtures/OtherFixtures.php diff --git a/Tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php b/tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php similarity index 100% rename from Tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php rename to tests/Fixtures/FooBundle/DataFixtures/RequiredConstructorArgsFixtures.php diff --git a/Tests/Fixtures/FooBundle/DataFixtures/WithDependenciesFixtures.php b/tests/Fixtures/FooBundle/DataFixtures/WithDependenciesFixtures.php similarity index 100% rename from Tests/Fixtures/FooBundle/DataFixtures/WithDependenciesFixtures.php rename to tests/Fixtures/FooBundle/DataFixtures/WithDependenciesFixtures.php diff --git a/Tests/Fixtures/FooBundle/FooBundle.php b/tests/Fixtures/FooBundle/FooBundle.php similarity index 100% rename from Tests/Fixtures/FooBundle/FooBundle.php rename to tests/Fixtures/FooBundle/FooBundle.php diff --git a/Tests/IntegrationTest.php b/tests/IntegrationTest.php similarity index 100% rename from Tests/IntegrationTest.php rename to tests/IntegrationTest.php diff --git a/Tests/IntegrationTestKernel.php b/tests/IntegrationTestKernel.php similarity index 100% rename from Tests/IntegrationTestKernel.php rename to tests/IntegrationTestKernel.php diff --git a/Tests/Purger/ORMPurgerFactoryTest.php b/tests/Purger/ORMPurgerFactoryTest.php similarity index 100% rename from Tests/Purger/ORMPurgerFactoryTest.php rename to tests/Purger/ORMPurgerFactoryTest.php