Unverified Commit 4747fd0c authored by belgattitude's avatar belgattitude Committed by Luís Cobucci

Latest reviews fixes: morozov, Majkl578

parent 5422bae0
......@@ -477,7 +477,7 @@ class MySqlPlatform extends AbstractPlatform
public function getDefaultValueDeclarationSQL($field)
{
// Unset the default value if the given field type does not allow default values.
if (!$this->isDefaultValueSupportedForType($field['type'])) {
if (! $this->isDefaultValueSupportedForType($field['type'])) {
$field['default'] = null;
}
......@@ -595,7 +595,7 @@ class MySqlPlatform extends AbstractPlatform
// Don't propagate default value changes for unsupported column types.
if ($columnDiff->hasChanged('default') &&
count($columnDiff->changedProperties) === 1 &&
!$this->isDefaultValueSupportedForType($columnArray['type'])
! $this->isDefaultValueSupportedForType($columnArray['type'])
) {
continue;
}
......
......@@ -180,7 +180,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
if ($this->_platform instanceof MariaDb1027Platform) {
$columnDefault = $this->getMariaDb1027ColumnDefault($this->_platform, $tableColumn['default']);
} else {
$columnDefault = (isset($tableColumn['default'])) ? $tableColumn['default'] : null;
$columnDefault = $tableColumn['default'];
}
$options = [
......@@ -237,7 +237,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
if ($columnDefault === 'NULL' || $columnDefault === null) {
return null;
}
if (strpos($columnDefault, "'") === 0) {
if ($columnDefault[0] === "'") {
return stripslashes(
str_replace("''", "'",
preg_replace('/^\'(.*)\'$/', '$1', $columnDefault)
......
......@@ -54,25 +54,25 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
return new MySqlSchemaManager($connection);
}
protected function getDatabasePlatformsForVersions()
protected function getDatabasePlatformsForVersions(): array
{
return array(
array('5.6.9', MySqlPlatform::class),
array('5.7', MySQL57Platform::class),
array('5.7.0', MySqlPlatform::class),
array('5.7.8', MySqlPlatform::class),
array('5.7.9', MySQL57Platform::class),
array('5.7.10', MySQL57Platform::class),
array('6', MySQL57Platform::class),
array('10.0.15-MariaDB-1~wheezy', MySqlPlatform::class),
array('5.5.5-10.1.25-MariaDB', MySqlPlatform::class),
array('10.1.2a-MariaDB-a1~lenny-log', MySqlPlatform::class),
array('5.5.40-MariaDB-1~wheezy', MySqlPlatform::class),
array('5.5.40-MariaDB-1~wheezy', MySqlPlatform::class),
array('5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class),
array('10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class),
array('10.2.8-MariaDB-1~lenny-log', MariaDb1027Platform::class)
);
return [
['5.6.9', MySqlPlatform::class],
['5.7', MySQL57Platform::class],
['5.7.0', MySqlPlatform::class],
['5.7.8', MySqlPlatform::class],
['5.7.9', MySQL57Platform::class],
['5.7.10', MySQL57Platform::class],
['6', MySQL57Platform::class],
['10.0.15-MariaDB-1~wheezy', MySqlPlatform::class],
['5.5.5-10.1.25-MariaDB', MySqlPlatform::class],
['10.1.2a-MariaDB-a1~lenny-log', MySqlPlatform::class],
['5.5.40-MariaDB-1~wheezy', MySqlPlatform::class],
['5.5.40-MariaDB-1~wheezy', MySqlPlatform::class],
['5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class],
['10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class],
['10.2.8-MariaDB-1~lenny-log', MariaDb1027Platform::class]
];
}
protected function getExceptionConversionData()
......
......@@ -35,12 +35,12 @@ class DriverTest extends PDOMySQLDriverTest
return new DrizzleSchemaManager($connection);
}
protected function getDatabasePlatformsForVersions()
protected function getDatabasePlatformsForVersions() : array
{
return array(
array('foo', 'Doctrine\DBAL\Platforms\DrizzlePlatform'),
array('bar', 'Doctrine\DBAL\Platforms\DrizzlePlatform'),
array('baz', 'Doctrine\DBAL\Platforms\DrizzlePlatform'),
);
return [
['foo', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
['bar', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
['baz', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
];
}
}
......@@ -908,19 +908,4 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
self::assertContains('bar', $sql);
self::assertNotContains('DATABASE()', $sql);
}
public function testGetDefaultValueDeclarationSQLIsQuotedWithLiteral()
{
$field = [
'type' => Type::getType('string'),
'default' => "'O'Connor said: \"Hello\" \ \r'"
];
self::assertSame(sprintf(
' DEFAULT %s',
$this->_platform->quoteStringLiteral("'O'Connor said: \"Hello\" \ \r'")
),
$this->_platform->getDefaultValueDeclarationSQL($field)
);
}
}
......@@ -976,19 +976,4 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
true
);
}
public function testGetDefaultValueDeclarationSQLIsQuotedWithLiteral()
{
$field = [
'type' => Type::getType('string'),
'default' => "'O'Connor said: \"Hello\" \ \r'"
];
self::assertSame(sprintf(
' DEFAULT %s',
$this->_platform->quoteStringLiteral("'O'Connor said: \"Hello\" \ \r'")
),
$this->_platform->getDefaultValueDeclarationSQL($field)
);
}
}
......@@ -12,22 +12,22 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
/**
* {@inheritdoc}
*/
public function createPlatform()
public function createPlatform() : MariaDb1027Platform
{
return new MariaDb1027Platform();
}
public function testHasNativeJsonType()
public function testHasNativeJsonType() : void
{
self::assertTrue($this->_platform->hasNativeJsonType());
}
public function testReturnsJsonTypeDeclarationSQL()
public function testReturnsJsonTypeDeclarationSQL() : void
{
self::assertSame('JSON', $this->_platform->getJsonTypeDeclarationSQL([]));
}
public function testInitializesJsonTypeMapping()
public function testInitializesJsonTypeMapping() : void
{
self::assertTrue($this->_platform->hasDoctrineTypeMappingFor('json'));
self::assertSame(Type::JSON, $this->_platform->getDoctrineTypeMapping('json'));
......@@ -39,7 +39,7 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
*
* @see AbstractMySQLPlatformTestCase::testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
*/
public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void
{
$this->markTestSkipped('MariaDB102Platform support propagation of default values for BLOB and TEXT columns');
}
......@@ -47,7 +47,7 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
/**
* Since MariaDB 10.2, Text and Blob can have a default value.
*/
public function testPropagateDefaultValuesForTextAndBlobColumnTypes()
public function testPropagateDefaultValuesForTextAndBlobColumnTypes() : void
{
$table = new Table("text_blob_default_value");
......@@ -69,7 +69,7 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
self::assertFalse($comparator->diffTable($table, $diffTable));
}
public function testPropagateDefaultValuesForJsonColumnType()
public function testPropagateDefaultValuesForJsonColumnType() : void
{
$table = new Table("text_json_default_value");
......
......@@ -874,19 +874,4 @@ EOD;
{
self::assertContains("'Foo''Bar\\\\'", $this->_platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\"), '', true);
}
public function testGetDefaultValueDeclarationSQLIsQuotedWithLiteral()
{
$field = [
'type' => Type::getType('string'),
'default' => "'O'Connor said: \"Hello\" \ \r'"
];
self::assertSame(sprintf(
' DEFAULT %s',
$this->_platform->quoteStringLiteral("'O'Connor said: \"Hello\" \ \r'")
),
$this->_platform->getDefaultValueDeclarationSQL($field)
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment