Skip to content

Commit 2e5fc45

Browse files
authored
CS: Relaxed EarlyExit rule (doctrine#891)
1 parent 60f9d0e commit 2e5fc45

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

phpcs.xml.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@
4343
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall.MissingTrailingComma">
4444
<exclude-pattern>src/Command/*</exclude-pattern>
4545
</rule>
46+
47+
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit">
48+
<properties>
49+
<property name="ignoreStandaloneIfInScope" value="true"/>
50+
<property name="ignoreOneLineTrailingIf" value="true"/>
51+
<property name="ignoreTrailingIfWithOneInstruction" value="true"/>
52+
</properties>
53+
</rule>
4654
</ruleset>

src/DependencyInjection/Compiler/FixturesCompilerPass.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ public function process(ContainerBuilder $container): void
2626
foreach ($taggedServices as $serviceId => $tags) {
2727
$groups = [];
2828
foreach ($tags as $tagData) {
29-
if (! isset($tagData['group'])) {
30-
continue;
29+
if (isset($tagData['group'])) {
30+
$groups[] = $tagData['group'];
3131
}
32-
33-
$groups[] = $tagData['group'];
3432
}
3533

3634
$fixtures[] = [

src/DependencyInjection/DoctrineMongoDBExtension.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,12 @@ protected function overrideParameters(array $options, ContainerBuilder $containe
205205
];
206206

207207
foreach ($overrides as $key) {
208-
if (! isset($options[$key])) {
209-
continue;
210-
}
211-
212-
$container->setParameter('doctrine_mongodb.odm.' . $key, $options[$key]);
208+
if (isset($options[$key])) {
209+
$container->setParameter('doctrine_mongodb.odm.' . $key, $options[$key]);
213210

214-
// the option should not be used, the parameter should be referenced
215-
unset($options[$key]);
211+
// the option should not be used, the parameter should be referenced
212+
unset($options[$key]);
213+
}
216214
}
217215

218216
return $options;
@@ -325,11 +323,9 @@ protected function loadDocumentManager(array $documentManager, string|null $defa
325323
foreach ($documentManager['filters'] as $name => $filter) {
326324
$parameters = $filter['parameters'] ?? [];
327325
$odmConfigDef->addMethodCall('addFilter', [$name, $filter['class'], $parameters]);
328-
if (! $filter['enabled']) {
329-
continue;
326+
if ($filter['enabled']) {
327+
$enabledFilters[] = $name;
330328
}
331-
332-
$enabledFilters[] = $name;
333329
}
334330

335331
$managerConfiguratorName = sprintf('doctrine_mongodb.odm.%s_manager_configurator', $documentManager['name']);
@@ -534,11 +530,9 @@ protected function loadDocumentManagerBundlesMappingInformation(array $documentM
534530
// TODO: Can we make a method out of it on Definition? replaceMethodArguments() or something.
535531
$calls = $odmConfigDef->getMethodCalls();
536532
foreach ($calls as $call) {
537-
if ($call[0] !== 'setDocumentNamespaces') {
538-
continue;
533+
if ($call[0] === 'setDocumentNamespaces') {
534+
$this->aliasMap = array_merge($call[1][0], $this->aliasMap);
539535
}
540-
541-
$this->aliasMap = array_merge($call[1][0], $this->aliasMap);
542536
}
543537

544538
$method = $odmConfigDef->removeMethodCall('setDocumentNamespaces');

0 commit comments

Comments
 (0)