Skip to content

Commit

Permalink
Use a modern directory structure
Browse files Browse the repository at this point in the history
The recommended directory structure is more similar to what we do in
non-bundle repositories.
Also, this means smaller configuration for tools such as PHPCSStandards,
PHPUnit or Psalm.
  • Loading branch information
greg0ire authored and ostrolucky committed Mar 15, 2024
1 parent 5afffe0 commit fa3e8e3
Show file tree
Hide file tree
Showing 270 changed files with 31 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -21,4 +21,4 @@ schema management and PDO abstraction.
## Documentation

The documentation is rendered on [the symfony.com website](https://symfony.com/doc/current/reference/configuration/doctrine.html).
The source of the documentation is available in the Resources/docs folder.
The source of the documentation is available in the docs folder.
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -81,12 +81,13 @@
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"Doctrine\\Bundle\\DoctrineBundle\\": ""
"Doctrine\\Bundle\\DoctrineBundle\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"": "Tests/DependencyInjection"
"": "tests/DependencyInjection",
"Doctrine\\Bundle\\DoctrineBundle\\Tests\\": "tests"
}
},
"config": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions phpcs.xml.dist
Expand Up @@ -11,8 +11,7 @@

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

<file>.</file>
<exclude-pattern>vendor/*</exclude-pattern>
<file>src</file>

<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>
Expand Down
11 changes: 3 additions & 8 deletions phpunit.xml.dist
@@ -1,20 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true" bootstrap="Tests/bootstrap.php">
<phpunit colors="true" bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="DoctrineBundle for the Symfony Framework">
<directory>./Tests</directory>
<directory>./tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>.</directory>
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
<directory>src</directory>
</whitelist>
</filter>

Expand Down
31 changes: 8 additions & 23 deletions psalm.xml.dist
Expand Up @@ -13,35 +13,20 @@
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
<!-- Deprecated classes, not worth fixing -->
<file name="Command/ImportMappingDoctrineCommand.php"/>
<file name="Command/Proxy/OrmProxyCommand.php"/>
<file name="DependencyInjection/Compiler/WellKnownSchemaFilterPass.php"/>
<file name="src/Command/ImportMappingDoctrineCommand.php"/>
<file name="src/Command/Proxy/OrmProxyCommand.php"/>
<file name="src/DependencyInjection/Compiler/WellKnownSchemaFilterPass.php"/>
</ignoreFiles>
<directory name="CacheWarmer"/>
<directory name="Command"/>
<directory name="Controller"/>
<directory name="DataCollector"/>
<directory name="Dbal"/>
<directory name="DependencyInjection"/>
<directory name="EventSubscriber"/>
<directory name="Mapping"/>
<directory name="Middleware"/>
<directory name="Repository"/>
<directory name="Tests"/>
<directory name="Twig"/>
<file name="ConnectionFactory.php"/>
<file name="DoctrineBundle.php"/>
<file name="ManagerConfigurator.php"/>
<file name="Registry.php"/>
</projectFiles>
<issueHandlers>
<RedundantPropertyInitializationCheck>
<errorLevel type="suppress">
<!-- Properties can be uninitialized in tests if setUp() fails. -->
<directory name="Tests"/>
<directory name="tests"/>
</errorLevel>
</RedundantPropertyInitializationCheck>
<UndefinedClass>
Expand All @@ -63,14 +48,14 @@
<DuplicateClass>
<errorLevel type="suppress">
<!-- Conditional class definition-->
<file name="Repository/RepositoryFactoryCompatibility.php"/>
<file name="Repository/ServiceEntityRepository.php"/>
<file name="src/Repository/RepositoryFactoryCompatibility.php"/>
<file name="src/Repository/ServiceEntityRepository.php"/>
</errorLevel>
</DuplicateClass>
<UndefinedMethod>
<errorLevel type="suppress">
<!-- Too tricky to configure very nested configuration in a way Psalm understands -->
<file name="DependencyInjection/Configuration.php" />
<file name="src/DependencyInjection/Configuration.php" />
</errorLevel>
</UndefinedMethod>
</issueHandlers>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -166,7 +166,7 @@ private function processConfigurationPrependingDefaults(ConfigurationInterface $
*/
protected function dbalLoad(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
$loader->load('dbal.xml');

if (empty($config['default_connection'])) {
Expand Down Expand Up @@ -447,7 +447,7 @@ protected function ormLoad(array $config, ContainerBuilder $container)
throw new LogicException('To configure the ORM layer, you must first install the doctrine/orm package.');
}

$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
$loader->load('orm.xml');

if (class_exists(AbstractType::class)) {
Expand Down Expand Up @@ -1116,7 +1116,7 @@ private function loadValidatorLoader(string $entityManagerName, ContainerBuilder

public function getXsdValidationBasePath(): string
{
return __DIR__ . '/../Resources/config/schema';
return __DIR__ . '/../../config/schema';
}

public function getNamespace(): string
Expand Down Expand Up @@ -1145,7 +1145,7 @@ private function loadMessengerServices(ContainerBuilder $container): void
return;
}

$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
$loader->load('messenger.xml');

// available in Symfony 6.3
Expand Down Expand Up @@ -1186,7 +1186,7 @@ private function registerDbalMiddlewares(
array $connWithProfiling,
array $connWithBacktrace
): void {
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
$loader->load('middlewares.xml');

$loggingMiddlewareAbstractDef = $container->getDefinition('doctrine.dbal.logging_middleware');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -39,7 +39,7 @@ private function createContainer(): ContainerBuilder
{
$container = new ContainerBuilder();

$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../config'));
$loader->load('middlewares.xml');

$container->addCompilerPass(new RemoveLoggingMiddlewarePass());
Expand Down
Expand Up @@ -19,7 +19,7 @@
<entity-manager name="em2" validate-xml-mapping="true">
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
dir="%kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
dir="%kernel.root_dir%/tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
alias="TestAlias"
/>
</entity-manager>
Expand Down
Expand Up @@ -16,7 +16,7 @@
<mapping name="AttributesBundle" type="attribute" />
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
dir="%kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
dir="%kernel.root_dir%/tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
alias="TestAlias"
/>
</orm>
Expand Down
Expand Up @@ -20,7 +20,7 @@
<mapping name="AttributesBundle" type="attribute" />
<mapping name="YamlBundle" dir="Resources/config/doctrine" alias="yml" />
<mapping name="manual" type="xml" prefix="Fixtures\Bundles\XmlBundle"
dir="%kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
dir="%kernel.root_dir%/tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
alias="TestAlias"
/>
</orm>
Expand Down
Expand Up @@ -22,5 +22,5 @@ doctrine:
manual:
type: xml
prefix: Fixtures\Bundles\XmlBundle
dir: "%kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
dir: "%kernel.root_dir%/tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
alias: TestAlias
Expand Up @@ -17,5 +17,5 @@ doctrine:
manual:
type: xml
prefix: Fixtures\Bundles\XmlBundle
dir: "%kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
dir: "%kernel.root_dir%/tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
alias: TestAlias
Expand Up @@ -19,5 +19,5 @@ doctrine:
manual:
type: xml
prefix: Fixtures\Bundles\XmlBundle
dir: "%kernel.root_dir%/Tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
dir: "%kernel.root_dir%/tests/DependencyInjection/Fixtures/Bundles/XmlBundle/Resources/config/doctrine"
alias: TestAlias
File renamed without changes.
File renamed without changes.
Expand Up @@ -43,7 +43,7 @@ public function testValidateSchema(string $file): void
$configNode->appendChild($dbalNode);
$dbalDom->appendChild($configNode);

$ret = $dbalDom->schemaValidate(__DIR__ . '/../../Resources/config/schema/doctrine-1.0.xsd');
$ret = $dbalDom->schemaValidate(__DIR__ . '/../../config/schema/doctrine-1.0.xsd');
$this->assertTrue($ret, 'DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.');
$found = true;
}
Expand All @@ -56,7 +56,7 @@ public function testValidateSchema(string $file): void
$configNode->appendChild($ormNode);
$ormDom->appendChild($configNode);

$ret = $ormDom->schemaValidate(__DIR__ . '/../../Resources/config/schema/doctrine-1.0.xsd');
$ret = $ormDom->schemaValidate(__DIR__ . '/../../config/schema/doctrine-1.0.xsd');
$this->assertTrue($ret, 'DoctrineBundle Dependency Injection XMLSchema did not validate this XML instance.');
$found = true;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Tests/ProfilerTest.php → tests/ProfilerTest.php
Expand Up @@ -50,7 +50,7 @@ public function setUp(): void
$registry->method('getManagers')->willReturn([]);
$this->collector = new DoctrineDataCollector($registry, true, $this->debugDataHolder);

$twigLoaderFilesystem = new FilesystemLoader(__DIR__ . '/../Resources/views/Collector');
$twigLoaderFilesystem = new FilesystemLoader(__DIR__ . '/../templates/Collector');
$twigLoaderFilesystem->addPath(__DIR__ . '/../vendor/symfony/web-profiler-bundle/Resources/views', 'WebProfiler');
$this->twig = new Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]);

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit fa3e8e3

Please sign in to comment.