Skip to content

Commit 546cd67

Browse files
authored
Merge pull request #3489 from amaabdou/feature/upgrade_doctrine_cs_6_0
Update doctrine coding standard from 5.0 to 6.0
2 parents 5b5c2c9 + bf06844 commit 546cd67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+129
-82
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"doctrine/event-manager": "^1.0"
2828
},
2929
"require-dev": {
30-
"doctrine/coding-standard": "^5.0",
30+
"doctrine/coding-standard": "^6.0",
3131
"jetbrains/phpstorm-stubs": "^2018.1.2",
3232
"phpstan/phpstan": "^0.11.3",
3333
"phpunit/phpunit": "^8.0",

composer.lock

Lines changed: 38 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Doctrine/DBAL/Configuration.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private function buildSchemaAssetsFilterFromExpression($filterExpression) : call
107107
if ($assetName instanceof AbstractAsset) {
108108
$assetName = $assetName->getName();
109109
}
110+
110111
return preg_match($filterExpression, $assetName);
111112
};
112113
}
@@ -116,7 +117,8 @@ private function buildSchemaAssetsFilterFromExpression($filterExpression) : call
116117
*/
117118
public function setSchemaAssetsFilter(?callable $callable = null) : ?callable
118119
{
119-
$this->_attributes['filterSchemaAssetsExpression'] = null;
120+
$this->_attributes['filterSchemaAssetsExpression'] = null;
121+
120122
return $this->_attributes['filterSchemaAssetsExpressionCallable'] = $callable;
121123
}
122124

lib/Doctrine/DBAL/Connection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ public function transactional(Closure $func)
11611161
try {
11621162
$res = $func($this);
11631163
$this->commit();
1164+
11641165
return $res;
11651166
} catch (Exception $e) {
11661167
$this->rollBack();

lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ private function bindTypedParameters()
225225
$streams[$parameter] = $value;
226226
$values[$parameter] = null;
227227
continue;
228-
} else {
229-
$types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING];
230228
}
229+
230+
$types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING];
231231
}
232232

233233
$values[$parameter] = $value;

lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ private static function findToken($statement, &$offset, $regex)
254254
{
255255
if (preg_match($regex, $statement, $matches, PREG_OFFSET_CAPTURE, $offset)) {
256256
$offset = $matches[0][1];
257+
257258
return $matches[0][0];
258259
}
259260

lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ public function quote($value, $type = ParameterType::STRING)
100100
{
101101
if (is_int($value)) {
102102
return $value;
103-
} elseif (is_float($value)) {
103+
}
104+
105+
if (is_float($value)) {
104106
return sprintf('%F', $value);
105107
}
106108

lib/Doctrine/DBAL/DriverManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ public static function getConnection(
174174
// check for existing pdo object
175175
if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) {
176176
throw DBALException::invalidPdoInstance();
177-
} elseif (isset($params['pdo'])) {
177+
}
178+
179+
if (isset($params['pdo'])) {
178180
$params['pdo']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
179181
$params['driver'] = 'pdo_' . $params['pdo']->getAttribute(PDO::ATTR_DRIVER_NAME);
180182
} else {

lib/Doctrine/DBAL/Platforms/AbstractPlatform.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2968,7 +2968,6 @@ public function getDateTimeTzTypeDeclarationSQL(array $fieldDeclaration)
29682968
return $this->getDateTimeTypeDeclarationSQL($fieldDeclaration);
29692969
}
29702970

2971-
29722971
/**
29732972
* Obtains DBMS specific SQL to be used to create date fields in statements
29742973
* like CREATE TABLE.

lib/Doctrine/DBAL/Platforms/DB2Platform.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ protected function _getCreateTableSQL($tableName, array $columns, array $options
501501
foreach ($indexes as $definition) {
502502
$sqls[] = $this->getCreateIndexSQL($definition, $tableName);
503503
}
504+
504505
return $sqls;
505506
}
506507

lib/Doctrine/DBAL/Platforms/OraclePlatform.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,13 @@ private function getSequenceCacheSQL(Sequence $sequence)
201201
{
202202
if ($sequence->getCache() === 0) {
203203
return ' NOCACHE';
204-
} elseif ($sequence->getCache() === 1) {
204+
}
205+
206+
if ($sequence->getCache() === 1) {
205207
return ' NOCACHE';
206-
} elseif ($sequence->getCache() > 1) {
208+
}
209+
210+
if ($sequence->getCache() > 1) {
207211
return ' CACHE ' . $sequence->getCache();
208212
}
209213

lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ private function convertSingleBooleanValue($value, $callback)
821821
}
822822

823823
if (is_bool($value) || is_numeric($value)) {
824-
return $callback($value ? true : false);
824+
return $callback((bool) $value);
825825
}
826826

827827
if (! is_string($value)) {

lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,12 +627,15 @@ public function getForeignKeyMatchClauseSQL($type)
627627
switch ((int) $type) {
628628
case self::FOREIGN_KEY_MATCH_SIMPLE:
629629
return 'SIMPLE';
630+
630631
break;
631632
case self::FOREIGN_KEY_MATCH_FULL:
632633
return 'FULL';
634+
633635
break;
634636
case self::FOREIGN_KEY_MATCH_SIMPLE_UNIQUE:
635637
return 'UNIQUE SIMPLE';
638+
636639
break;
637640
case self::FOREIGN_KEY_MATCH_FULL_UNIQUE:
638641
return 'UNIQUE FULL';

lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,6 +1349,7 @@ private function scrubInnerOrderBy($query)
13491349
$query = substr($query, 0, $orderByPos) . substr($query, $currentPosition - 1);
13501350
$offset = $orderByPos;
13511351
}
1352+
13521353
return $query;
13531354
}
13541355

lib/Doctrine/DBAL/Platforms/SqlitePlatform.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,12 +1070,14 @@ private function getIndexesInAlteredTable(TableDiff $diff)
10701070
if (! isset($columnNames[$normalizedColumnName])) {
10711071
unset($indexes[$key]);
10721072
continue 2;
1073-
} else {
1074-
$indexColumns[] = $columnNames[$normalizedColumnName];
1075-
if ($columnName !== $columnNames[$normalizedColumnName]) {
1076-
$changed = true;
1077-
}
10781073
}
1074+
1075+
$indexColumns[] = $columnNames[$normalizedColumnName];
1076+
if ($columnName === $columnNames[$normalizedColumnName]) {
1077+
continue;
1078+
}
1079+
1080+
$changed = true;
10791081
}
10801082

10811083
if (! $changed) {
@@ -1122,12 +1124,14 @@ private function getForeignKeysInAlteredTable(TableDiff $diff)
11221124
if (! isset($columnNames[$normalizedColumnName])) {
11231125
unset($foreignKeys[$key]);
11241126
continue 2;
1125-
} else {
1126-
$localColumns[] = $columnNames[$normalizedColumnName];
1127-
if ($columnName !== $columnNames[$normalizedColumnName]) {
1128-
$changed = true;
1129-
}
11301127
}
1128+
1129+
$localColumns[] = $columnNames[$normalizedColumnName];
1130+
if ($columnName === $columnNames[$normalizedColumnName]) {
1131+
continue;
1132+
}
1133+
1134+
$changed = true;
11311135
}
11321136

11331137
if (! $changed) {

lib/Doctrine/DBAL/Query/QueryBuilder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,6 @@ public function groupBy($groupBy)
866866
return $this->add('groupBy', $groupBy, false);
867867
}
868868

869-
870869
/**
871870
* Adds a grouping expression to the query.
872871
*
@@ -1188,6 +1187,7 @@ private function getSQLForInsert()
11881187
private function getSQLForUpdate()
11891188
{
11901189
$table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
1190+
11911191
return 'UPDATE ' . $table
11921192
. ' SET ' . implode(', ', $this->sqlParts['set'])
11931193
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
@@ -1201,6 +1201,7 @@ private function getSQLForUpdate()
12011201
private function getSQLForDelete()
12021202
{
12031203
$table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
1204+
12041205
return 'DELETE FROM ' . $table . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
12051206
}
12061207

0 commit comments

Comments
 (0)