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

Code cleanup #4739

Merged
merged 2 commits into from
Aug 1, 2021
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
2 changes: 1 addition & 1 deletion src/Cache/QueryCacheProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class QueryCacheProfile
private $resultCacheDriver;

/** @var int */
private $lifetime = 0;
private $lifetime;

/** @var string|null */
private $cacheKey;
Expand Down
2 changes: 1 addition & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ private function extractTypeValues(array $columnList, array $types)
{
$typeValues = [];

foreach ($columnList as $columnIndex => $columnName) {
foreach ($columnList as $columnName) {
$typeValues[] = $types[$columnName] ?? ParameterType::STRING;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Driver/IBMDB2/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function execute($params = null): ResultInterface

$params = [];

foreach ($this->bindParam as $column => $value) {
foreach ($this->bindParam as $value) {
$params[] = $value;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Logging/LoggerChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class LoggerChain implements SQLLogger
{
/** @var iterable<SQLLogger> */
private $loggers = [];
private $loggers;

/**
* @param iterable<SQLLogger> $loggers
Expand Down
2 changes: 1 addition & 1 deletion src/Platforms/Keywords/ReservedKeywordsValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class ReservedKeywordsValidator implements Visitor
{
/** @var KeywordList[] */
private $keywordLists = [];
private $keywordLists;

/** @var string[] */
private $violations = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Index extends AbstractAsset implements Constraint
* @todo $_flags should eventually be refactored into options
* @var mixed[]
*/
private $options = [];
private $options;

/**
* @param string $name
Expand Down
7 changes: 2 additions & 5 deletions src/Schema/PostgreSQLSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,8 @@ public function determineExistingSchemaSearchPaths()
*/
protected function _getPortableTableForeignKeyDefinition($tableForeignKey)
{
$onUpdate = null;
$onDelete = null;
$localColumns = [];
$foreignColumns = [];
$foreignTable = null;
$onUpdate = null;
$onDelete = null;

if (
preg_match(
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/UniqueConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class UniqueConstraint extends AbstractAsset implements Constraint
*
* @var mixed[]
*/
private $options = [];
private $options;

/**
* @param string[] $columns
Expand Down
3 changes: 1 addition & 2 deletions src/Tools/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public static function dump($var, int $maxDepth = 2): string
*/
public static function export($var, int $maxDepth)
{
$return = null;
$isObj = is_object($var);
$isObj = is_object($var);

if ($var instanceof Collection) {
$var = $var->toArray();
Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/QueryCacheProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function testConnectionParamsShouldBeHashed(): void
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);

[$cacheKey, $queryString] = $this->queryCacheProfile->generateCacheKeys(
[, $queryString] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
$this->params,
$this->types,
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/PrimaryReadReplicaConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function testPrimaryOnWriteOperation(): void

public function testKeepReplicaBeginTransactionStaysOnPrimary(): void
{
$conn = $this->createPrimaryReadReplicaConnection($keepReplica = true);
$conn = $this->createPrimaryReadReplicaConnection(true);
$conn->ensureConnectedToReplica();

$conn->beginTransaction();
Expand All @@ -158,7 +158,7 @@ public function testKeepReplicaBeginTransactionStaysOnPrimary(): void

public function testKeepReplicaInsertStaysOnPrimary(): void
{
$conn = $this->createPrimaryReadReplicaConnection($keepReplica = true);
$conn = $this->createPrimaryReadReplicaConnection(true);
$conn->ensureConnectedToReplica();

$conn->insert('primary_replica_table', ['test_int' => 30]);
Expand Down
6 changes: 2 additions & 4 deletions tests/Functional/ResultCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ public function testFetchAndFinishSavesCache(): void
new QueryCacheProfile(0, 'testcachekey')
);

while (($row = $result->fetchAssociative()) !== false) {
}
$result->fetchAllAssociative();

$result = $this->connection->executeQuery(
'SELECT * FROM caching ORDER BY test_int ASC',
Expand All @@ -181,8 +180,7 @@ public function testFetchAndFinishSavesCache(): void
new QueryCacheProfile(0, 'testcachekey')
);

while (($row = $result->fetchNumeric()) !== false) {
}
$result->fetchAllNumeric();

self::assertCount(1, $this->sqlLogger->queries);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Schema/MySQLSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public function testColumnCharsetChange(): void
public function testColumnCollation(): void
{
$table = new Table('test_collation');
$table->addOption('collate', $collation = 'latin1_swedish_ci');
$table->addOption('collate', 'latin1_swedish_ci');
$table->addOption('charset', 'latin1');
$table->addColumn('id', 'integer');
$table->addColumn('text', 'text');
Expand Down
6 changes: 3 additions & 3 deletions tests/Functional/Schema/PostgreSQLSchemaManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testDetectsAutoIncrement(): void
public function testAlterTableAutoIncrementAdd(): void
{
$tableFrom = new Table('autoinc_table_add');
$column = $tableFrom->addColumn('id', 'integer');
$tableFrom->addColumn('id', 'integer');
$this->schemaManager->createTable($tableFrom);
$tableFrom = $this->schemaManager->listTableDetails('autoinc_table_add');
self::assertFalse($tableFrom->getColumn('id')->getAutoincrement());
Expand Down Expand Up @@ -192,10 +192,10 @@ public function testReturnQuotedAssets(): void
public function testFilterSchemaExpression(): void
{
$testTable = new Table('dbal204_test_prefix');
$column = $testTable->addColumn('id', 'integer');
$testTable->addColumn('id', 'integer');
$this->schemaManager->createTable($testTable);
$testTable = new Table('dbal204_without_prefix');
$column = $testTable->addColumn('id', 'integer');
$testTable->addColumn('id', 'integer');
$this->schemaManager->createTable($testTable);

$this->connection->getConfiguration()->setSchemaAssetsFilter(static function (string $name): bool {
Expand Down
16 changes: 8 additions & 8 deletions tests/Platforms/AbstractPlatformTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function testCreateWithNoColumns(): void
$table = new Table('test');

$this->expectException(Exception::class);
$sql = $this->platform->getCreateTableSQL($table);
$this->platform->getCreateTableSQL($table);
}

public function testGeneratesTableCreationSql(): void
Expand Down Expand Up @@ -218,22 +218,22 @@ public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes()

$expected = ' WHERE ' . $where;

$actuals = [];
$indexes = [];

if ($this->supportsInlineIndexDeclaration()) {
$actuals[] = $this->platform->getIndexDeclarationSQL('name', $indexDef);
$indexes[] = $this->platform->getIndexDeclarationSQL('name', $indexDef);
}

$uniqueConstraintSQL = $this->platform->getUniqueConstraintDeclarationSQL('name', $uniqueConstraint);
$indexSQL = $this->platform->getCreateIndexSQL($indexDef, 'table');

$this->assertStringEndsNotWith($expected, $uniqueConstraintSQL, 'WHERE clause should NOT be present');

foreach ($actuals as $actual) {
$indexes[] = $this->platform->getCreateIndexSQL($indexDef, 'table');

foreach ($indexes as $index) {
if ($this->platform->supportsPartialIndexes()) {
self::assertStringEndsWith($expected, $indexSQL, 'WHERE clause should be present');
self::assertStringEndsWith($expected, $index, 'WHERE clause should be present');
} else {
self::assertStringEndsNotWith($expected, $indexSQL, 'WHERE clause should NOT be present');
self::assertStringEndsNotWith($expected, $index, 'WHERE clause should NOT be present');
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions tests/Platforms/AbstractPostgreSQLPlatformTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,7 @@ protected function getQuotedColumnInForeignKeySQL(): array
*/
public function testConvertBooleanAsLiteralStrings(
$databaseValue,
string $preparedStatementValue,
?int $integerValue,
?bool $booleanValue
string $preparedStatementValue
): void {
$platform = $this->createPlatform();

Expand Down
2 changes: 0 additions & 2 deletions tests/Platforms/OraclePlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): vo
$table2->addColumn('column_varbinary', 'binary', ['fixed' => true]);
$table2->addColumn('column_binary', 'binary');

$comparator = new Comparator();

// VARBINARY -> BINARY
// BINARY -> VARBINARY
$diff = (new Comparator())->diffTable($table1, $table2);
Expand Down
Loading