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

Use PHP 7.4 for phpcs #768

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ jobs:
driver-version: "1.5.0"
stability: "stable"
symfony-version: "4.4.*"
# Remove this job when releasing mongodb-odm 2.5
- dependencies: "highest"
os: "ubuntu-20.04"
php-version: "8.2"
driver-version: "stable"
stability: "dev"
symfony-version: "6.2.*"
exclude:
- php-version: "7.4"
symfony-version: "6.2.x"
Expand Down
4 changes: 2 additions & 2 deletions DataCollector/CommandDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ static function (Command $command): array {
'durationMicros' => $command->getDurationMicros(),
];
},
$this->commandLogger->getAll()
$this->commandLogger->getAll(),
),
'time' => array_reduce(
$this->commandLogger->getAll(),
static fn (int $total, Command $command): int => $total + $command->getDurationMicros(),
0
0,
),
];
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/CacheCompatibilityPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function createCompatibilityLayerDefinition(ContainerBuilder $container,
'doctrine/mongodb-odm-bundle',
'4.4',
'Configuring doctrine/cache is deprecated. Please update the cache service "%s" to use a PSR-6 cache.',
$definitionId
$definitionId,
);
}

Expand All @@ -90,7 +90,7 @@ private function wrapIfNecessary(ContainerBuilder $container, ?string $aliasId,
return;
}

$aliasId = $aliasId ?? $definitionId;
$aliasId ??= $definitionId;

$compatibilityLayerId = $definitionId . '.compatibility_layer';
$container->setDefinition($compatibilityLayerId, $compatibilityLayer);
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/CreateHydratorDirectoryPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public function process(ContainerBuilder $container)
if (! is_dir($hydratorCacheDir)) {
if (@mkdir($hydratorCacheDir, 0775, true) === false && ! is_dir($hydratorCacheDir)) {
throw new RuntimeException(
sprintf('Unable to create the Doctrine Hydrator directory (%s)', dirname($hydratorCacheDir))
sprintf('Unable to create the Doctrine Hydrator directory (%s)', dirname($hydratorCacheDir)),
);
}
} elseif (! is_writable($hydratorCacheDir)) {
throw new RuntimeException(
sprintf('Unable to write in the Doctrine Hydrator directory (%s)', $hydratorCacheDir)
sprintf('Unable to write in the Doctrine Hydrator directory (%s)', $hydratorCacheDir),
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions DependencyInjection/Compiler/CreateProxyDirectoryPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public function process(ContainerBuilder $container)
if (! is_dir($proxyCacheDir)) {
if (@mkdir($proxyCacheDir, 0775, true) === false && ! is_dir($proxyCacheDir)) {
throw new RuntimeException(
sprintf('Unable to create the Doctrine Proxy directory (%s)', dirname($proxyCacheDir))
sprintf('Unable to create the Doctrine Proxy directory (%s)', dirname($proxyCacheDir)),
);
}
} elseif (! is_writable($proxyCacheDir)) {
throw new RuntimeException(
sprintf('Unable to write in the Doctrine Proxy directory (%s)', $proxyCacheDir)
sprintf('Unable to write in the Doctrine Proxy directory (%s)', $proxyCacheDir),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct($driver, array $namespaces, array $managerParameters
$enabledParameter,
'doctrine_mongodb.odm.%s_configuration',
'addDocumentNamespace',
$aliasMap
$aliasMap,
);
}

Expand Down
18 changes: 9 additions & 9 deletions DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function load(array $configs, ContainerBuilder $container)
$config['document_managers'],
$config['default_document_manager'],
$config['default_database'],
$container
$container,
);

if ($config['resolve_target_documents']) {
Expand Down Expand Up @@ -237,7 +237,7 @@ protected function loadDocumentManagers(array $dmConfigs, $defaultDM, $defaultDB
$documentManager,
$defaultDM,
$defaultDB,
$container
$container,
);
$dms[$name] = sprintf('doctrine_mongodb.odm.%s_document_manager', $name);
}
Expand All @@ -263,7 +263,7 @@ protected function loadDocumentManager(array $documentManager, $defaultDM, $defa
$odmConfigDef->addTag(self::CONFIGURATION_TAG);
$container->setDefinition(
$configurationId,
$odmConfigDef
$odmConfigDef,
);

$this->loadDocumentManagerBundlesMappingInformation($documentManager, $odmConfigDef, $container);
Expand Down Expand Up @@ -298,7 +298,7 @@ protected function loadDocumentManager(array $documentManager, $defaultDM, $defa
$container->getAlias('doctrine_mongodb.odm.command_logger')
->setDeprecated(...$this->buildDeprecationArgs(
'4.4',
'The service %alias_id% is deprecated and will be dropped in DoctrineMongoDBBundle 5.0. Use "doctrine_mongodb.odm.psr_command_logger" instead.'
'The service %alias_id% is deprecated and will be dropped in DoctrineMongoDBBundle 5.0. Use "doctrine_mongodb.odm.psr_command_logger" instead.',
));

// logging
Expand Down Expand Up @@ -336,7 +336,7 @@ protected function loadDocumentManager(array $documentManager, $defaultDM, $defa
$container
->setDefinition(
$managerConfiguratorName,
new ChildDefinition('doctrine_mongodb.odm.manager_configurator.abstract')
new ChildDefinition('doctrine_mongodb.odm.manager_configurator.abstract'),
)
->replaceArgument(0, $enabledFilters);

Expand Down Expand Up @@ -369,13 +369,13 @@ protected function loadDocumentManager(array $documentManager, $defaultDM, $defa

$container->setAlias(
'doctrine_mongodb.odm.document_manager',
new Alias(sprintf('doctrine_mongodb.odm.%s_document_manager', $documentManager['name']))
new Alias(sprintf('doctrine_mongodb.odm.%s_document_manager', $documentManager['name'])),
);
$container->getAlias('doctrine_mongodb.odm.document_manager')->setPublic(true);

$container->setAlias(
'doctrine_mongodb.odm.event_manager',
new Alias(sprintf('doctrine_mongodb.odm.%s_connection.event_manager', $connectionName))
new Alias(sprintf('doctrine_mongodb.odm.%s_connection.event_manager', $connectionName)),
);
}

Expand All @@ -393,13 +393,13 @@ protected function loadConnections(array $connections, ContainerBuilder $contain
$eventManagerId = sprintf('doctrine_mongodb.odm.%s_connection.event_manager', $name);
$container->setDefinition(
$eventManagerId,
new ChildDefinition('doctrine_mongodb.odm.connection.event_manager')
new ChildDefinition('doctrine_mongodb.odm.connection.event_manager'),
);

$configurationId = sprintf('doctrine_mongodb.odm.%s_configuration', $name);
$container->setDefinition(
$configurationId,
new Definition('%doctrine_mongodb.odm.configuration.class%')
new Definition('%doctrine_mongodb.odm.configuration.class%'),
);

$odmConnArgs = [
Expand Down
18 changes: 9 additions & 9 deletions Form/DoctrineMongoDBTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function guessType($class, $property)
'multiple' => $multiple,
'expanded' => $multiple,
],
Guess::HIGH_CONFIDENCE
Guess::HIGH_CONFIDENCE,
);
}

Expand All @@ -78,45 +78,45 @@ public function guessType($class, $property)
return new TypeGuess(
CollectionType::class,
[],
Guess::MEDIUM_CONFIDENCE
Guess::MEDIUM_CONFIDENCE,
);

case Type::BOOL:
case Type::BOOLEAN:
return new TypeGuess(
CheckboxType::class,
[],
Guess::HIGH_CONFIDENCE
Guess::HIGH_CONFIDENCE,
);

case Type::DATE:
case Type::TIMESTAMP:
return new TypeGuess(
DateTimeType::class,
[],
Guess::HIGH_CONFIDENCE
Guess::HIGH_CONFIDENCE,
);

case Type::FLOAT:
return new TypeGuess(
NumberType::class,
[],
Guess::MEDIUM_CONFIDENCE
Guess::MEDIUM_CONFIDENCE,
);

case Type::INT:
case Type::INTEGER:
return new TypeGuess(
IntegerType::class,
[],
Guess::MEDIUM_CONFIDENCE
Guess::MEDIUM_CONFIDENCE,
);

case Type::STRING:
return new TypeGuess(
TextType::class,
[],
Guess::MEDIUM_CONFIDENCE
Guess::MEDIUM_CONFIDENCE,
);
}
}
Expand All @@ -134,13 +134,13 @@ public function guessRequired($class, $property)
if (! $ret[0]->isNullable($property)) {
return new ValueGuess(
true,
Guess::HIGH_CONFIDENCE
Guess::HIGH_CONFIDENCE,
);
}

return new ValueGuess(
false,
Guess::MEDIUM_CONFIDENCE
Guess::MEDIUM_CONFIDENCE,
);
}

Expand Down
2 changes: 1 addition & 1 deletion Form/Type/DocumentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getLoader(ObjectManager $manager, $queryBuilder, $class): Entity
return new MongoDBQueryBuilderLoader(
$queryBuilder,
$manager,
$class
$class,
);
}

Expand Down
2 changes: 1 addition & 1 deletion Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function createFixture($class)
throw new LogicException(sprintf(
'The "%s" fixture class is trying to be loaded, but is not available. Make sure this class is defined as a service and tagged with "%s".',
$class,
FixturesCompilerPass::FIXTURE_TAG
FixturesCompilerPass::FIXTURE_TAG,
));
}

Expand Down
2 changes: 1 addition & 1 deletion Repository/ServiceRepositoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(ManagerRegistry $registry, $documentClass)
if ($manager === null) {
throw new LogicException(sprintf(
'Could not find the document manager for class "%s". Check your Doctrine configuration to make sure it is configured to load this document’s metadata.',
$documentClass
$documentClass,
));
}

Expand Down
10 changes: 5 additions & 5 deletions Tests/DependencyInjection/AbstractMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function testBundleDocumentAliases(): void
$loader = new DoctrineMongoDBExtension();

$config = DoctrineMongoDBExtensionTest::buildConfiguration(
['document_managers' => ['default' => ['mappings' => ['XmlBundle' => []]]]]
['document_managers' => ['default' => ['mappings' => ['XmlBundle' => []]]]],
);
$loader->load($config, $container);

Expand All @@ -298,7 +298,7 @@ public function testXmlBundleMappingDetection(): void
$container = $this->getContainer('XmlBundle');
$loader = new DoctrineMongoDBExtension();
$config = DoctrineMongoDBExtensionTest::buildConfiguration(
['document_managers' => ['default' => ['mappings' => ['XmlBundle' => []]]]]
['document_managers' => ['default' => ['mappings' => ['XmlBundle' => []]]]],
);
$loader->load($config, $container);

Expand All @@ -316,7 +316,7 @@ public function testNewBundleStructureXmlBundleMappingDetection(): void
$container = $this->getContainer('NewXmlBundle');
$loader = new DoctrineMongoDBExtension();
$config = DoctrineMongoDBExtensionTest::buildConfiguration(
['document_managers' => ['default' => ['mappings' => ['NewXmlBundle' => []]]]]
['document_managers' => ['default' => ['mappings' => ['NewXmlBundle' => []]]]],
);
$loader->load($config, $container);

Expand All @@ -330,7 +330,7 @@ public function testAnnotationsBundleMappingDetection(): void
$container = $this->getContainer('AnnotationsBundle');
$loader = new DoctrineMongoDBExtension();
$config = DoctrineMongoDBExtensionTest::buildConfiguration(
['document_managers' => ['default' => ['mappings' => ['AnnotationsBundle' => []]]]]
['document_managers' => ['default' => ['mappings' => ['AnnotationsBundle' => []]]]],
);
$loader->load($config, $container);

Expand All @@ -349,7 +349,7 @@ public function testAttributesBundleMappingDetection(): void
$container = $this->getContainer('AttributesBundle');
$loader = new DoctrineMongoDBExtension();
$config = DoctrineMongoDBExtensionTest::buildConfiguration(
['document_managers' => ['default' => ['mappings' => ['AttributesBundle' => 'attribute']]]]
['document_managers' => ['default' => ['mappings' => ['AttributesBundle' => 'attribute']]]],
);
$loader->load($config, $container);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
$loader->load(static function (ContainerBuilder $containerBuilder): void {
$containerBuilder->loadFromExtension(
'doctrine_mongodb',
['document_managers' => ['default' => ['metadata_cache_driver' => ['type' => 'service', 'id' => 'custom_cache_service']]]]
['document_managers' => ['default' => ['metadata_cache_driver' => ['type' => 'service', 'id' => 'custom_cache_service']]]],
);
$containerBuilder->setDefinition(
'custom_cache_service',
new Definition(ArrayAdapter::class)
new Definition(ArrayAdapter::class),
);
});
}
Expand All @@ -57,13 +57,13 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
$loader->load(static function (ContainerBuilder $containerBuilder): void {
$containerBuilder->loadFromExtension(
'doctrine_mongodb',
['document_managers' => ['default' => ['metadata_cache_driver' => ['type' => 'service', 'id' => 'custom_cache_service']]]]
['document_managers' => ['default' => ['metadata_cache_driver' => ['type' => 'service', 'id' => 'custom_cache_service']]]],
);
$containerBuilder->setDefinition(
'custom_cache_service',
(new Definition(DoctrineProvider::class))
->setArguments([new Definition(ArrayAdapter::class)])
->setFactory([DoctrineProvider::class, 'wrap'])
->setFactory([DoctrineProvider::class, 'wrap']),
);
});
}
Expand Down
12 changes: 6 additions & 6 deletions Tests/DependencyInjection/DoctrineMongoDBExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function buildConfiguration(array $settings = []): array
'connections' => ['default' => []],
'document_managers' => ['default' => []],
],
$settings
$settings,
),
];
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public function testAutomapping(array $documentManagers): void
'document_managers' => $documentManagers,
],
],
$container
$container,
);

$configDm1 = $container->getDefinition('doctrine_mongodb.odm.dm1_configuration');
Expand All @@ -244,7 +244,7 @@ public function testAutomapping(array $documentManagers): void
['OtherXmlBundle' => 'Doctrine\Bundle\MongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\OtherXmlBundle\Document'],
],
],
$configDm1->getMethodCalls()
$configDm1->getMethodCalls(),
);

$this->assertContains(
Expand All @@ -254,7 +254,7 @@ public function testAutomapping(array $documentManagers): void
['XmlBundle' => 'Doctrine\Bundle\MongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\XmlBundle\Document'],
],
],
$configDm2->getMethodCalls()
$configDm2->getMethodCalls(),
);

$this->assertContains(
Expand All @@ -264,7 +264,7 @@ public function testAutomapping(array $documentManagers): void
['NewXmlBundle' => 'Doctrine\Bundle\MongoDBBundle\Tests\DependencyInjection\Fixtures\Bundles\NewXmlBundle\Document'],
],
],
$configDm3->getMethodCalls()
$configDm3->getMethodCalls(),
);
}

Expand All @@ -290,7 +290,7 @@ public function testFactoriesAreRegistered(): void
],
],
],
$container
$container,
);

$configDm1 = $container->getDefinition('doctrine_mongodb.odm.dm1_configuration');
Expand Down
Loading