Skip to content

Commit e125a45

Browse files
authored
Merge pull request #2980 from carusogabriel/simplify-returns
Simplify returns
2 parents 0dbcf1f + 3d75905 commit e125a45

File tree

4 files changed

+9
-45
lines changed

4 files changed

+9
-45
lines changed

lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ class Connection extends \Doctrine\DBAL\Driver\PDOConnection
3030
public function quote($value, $type = \PDO::PARAM_STR)
3131
{
3232
if (\PDO::PARAM_BOOL === $type) {
33-
if ($value) {
34-
return 'true';
35-
}
36-
37-
return 'false';
33+
return $value ? 'true' : 'false';
3834
}
3935

4036
return parent::quote($value, $type);

lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,7 @@ private function alterColumnRequiresDropDefaultConstraint(ColumnDiff $columnDiff
654654

655655
// We need to drop an existing default constraint if the column was
656656
// defined with a default value before and the native column type has changed.
657-
if ($columnDiff->hasChanged('type') || $columnDiff->hasChanged('fixed')) {
658-
return true;
659-
}
660-
661-
return false;
657+
return $columnDiff->hasChanged('type') || $columnDiff->hasChanged('fixed');
662658
}
663659

664660
/**
@@ -1320,11 +1316,7 @@ private function isOrderByInTopNSubquery($query, $currentPosition)
13201316
$currentPosition--;
13211317
}
13221318

1323-
if (preg_match('/SELECT\s+(DISTINCT\s+)?TOP\s/i', $subQueryBuffer)) {
1324-
return true;
1325-
}
1326-
1327-
return false;
1319+
return (bool) preg_match('/SELECT\s+(DISTINCT\s+)?TOP\s/i', $subQueryBuffer);
13281320
}
13291321

13301322
/**

lib/Doctrine/DBAL/Schema/Comparator.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,7 @@ public function diffSequence(Sequence $sequence1, Sequence $sequence2)
184184
return true;
185185
}
186186

187-
if ($sequence1->getInitialValue() != $sequence2->getInitialValue()) {
188-
return true;
189-
}
190-
191-
return false;
187+
return $sequence1->getInitialValue() !== $sequence2->getInitialValue();
192188
}
193189

194190
/**
@@ -406,11 +402,7 @@ public function diffForeignKey(ForeignKeyConstraint $key1, ForeignKeyConstraint
406402
return true;
407403
}
408404

409-
if ($key1->onDelete() != $key2->onDelete()) {
410-
return true;
411-
}
412-
413-
return false;
405+
return $key1->onDelete() !== $key2->onDelete();
414406
}
415407

416408
/**
@@ -534,10 +526,6 @@ private function isALegacyJsonComparison(Types\Type $one, Types\Type $other) : b
534526
*/
535527
public function diffIndex(Index $index1, Index $index2)
536528
{
537-
if ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1)) {
538-
return false;
539-
}
540-
541-
return true;
529+
return ! ($index1->isFullfilledBy($index2) && $index2->isFullfilledBy($index1));
542530
}
543531
}

lib/Doctrine/DBAL/Schema/Index.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,7 @@ public function isFullfilledBy(Index $other)
226226
return false;
227227
}
228228

229-
if ($other->isUnique() != $this->isUnique()) {
230-
return false;
231-
}
232-
233-
return true;
229+
return $other->isUnique() === $this->isUnique();
234230
}
235231

236232
return false;
@@ -251,11 +247,7 @@ public function overrules(Index $other)
251247
return false;
252248
}
253249

254-
if ($this->spansColumns($other->getColumns()) && ($this->isPrimary() || $this->isUnique()) && $this->samePartialIndex($other)) {
255-
return true;
256-
}
257-
258-
return false;
250+
return $this->spansColumns($other->getColumns()) && ($this->isPrimary() || $this->isUnique()) && $this->samePartialIndex($other);
259251
}
260252

261253
/**
@@ -348,11 +340,7 @@ private function samePartialIndex(Index $other)
348340
return true;
349341
}
350342

351-
if ( ! $this->hasOption('where') && ! $other->hasOption('where')) {
352-
return true;
353-
}
354-
355-
return false;
343+
return ! $this->hasOption('where') && ! $other->hasOption('where');
356344
}
357345

358346
}

0 commit comments

Comments
 (0)