Use in_array() in strict mode

parent 182d3d8f
...@@ -195,7 +195,7 @@ final class DriverManager ...@@ -195,7 +195,7 @@ final class DriverManager
throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap)); throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap));
} }
if (isset($params['driverClass']) && ! in_array(Driver::class, class_implements($params['driverClass'], true))) { if (isset($params['driverClass']) && ! in_array(Driver::class, class_implements($params['driverClass']), true)) {
throw DBALException::invalidDriverClass($params['driverClass']); throw DBALException::invalidDriverClass($params['driverClass']);
} }
} }
......
...@@ -494,7 +494,7 @@ abstract class AbstractPlatform ...@@ -494,7 +494,7 @@ abstract class AbstractPlatform
assert(is_array($this->doctrineTypeComments)); assert(is_array($this->doctrineTypeComments));
return in_array($doctrineType->getName(), $this->doctrineTypeComments); return in_array($doctrineType->getName(), $this->doctrineTypeComments, true);
} }
/** /**
...@@ -1586,7 +1586,7 @@ abstract class AbstractPlatform ...@@ -1586,7 +1586,7 @@ abstract class AbstractPlatform
$columnData['length'] = 255; $columnData['length'] = 255;
} }
if (in_array($column->getName(), $options['primary'])) { if (in_array($column->getName(), $options['primary'], true)) {
$columnData['primary'] = true; $columnData['primary'] = true;
} }
......
...@@ -765,7 +765,7 @@ SQL ...@@ -765,7 +765,7 @@ SQL
$column = $diff->fromTable->getColumn($columnName); $column = $diff->fromTable->getColumn($columnName);
// Check if an autoincrement column was dropped from the primary key. // Check if an autoincrement column was dropped from the primary key.
if (! $column->getAutoincrement() || in_array($columnName, $changedIndex->getColumns())) { if (! $column->getAutoincrement() || in_array($columnName, $changedIndex->getColumns(), true)) {
continue; continue;
} }
......
...@@ -40,7 +40,7 @@ class ColumnDiff ...@@ -40,7 +40,7 @@ class ColumnDiff
*/ */
public function hasChanged($propertyName) public function hasChanged($propertyName)
{ {
return in_array($propertyName, $this->changedProperties); return in_array($propertyName, $this->changedProperties, true);
} }
/** /**
......
...@@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Schema; ...@@ -5,7 +5,6 @@ namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use function array_keys; use function array_keys;
use function array_map; use function array_map;
use function in_array;
use function strrpos; use function strrpos;
use function strtolower; use function strtolower;
use function strtoupper; use function strtoupper;
...@@ -360,7 +359,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint ...@@ -360,7 +359,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
if (isset($this->_options[$event])) { if (isset($this->_options[$event])) {
$onEvent = strtoupper($this->_options[$event]); $onEvent = strtoupper($this->_options[$event]);
if (! in_array($onEvent, ['NO ACTION', 'RESTRICT'])) { if ($onEvent !== 'NO ACTION' && $onEvent !== 'RESTRICT') {
return $onEvent; return $onEvent;
} }
} }
......
...@@ -94,7 +94,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -94,7 +94,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$paths = $this->getSchemaSearchPaths(); $paths = $this->getSchemaSearchPaths();
$this->existingSchemaPaths = array_filter($paths, static function ($v) use ($names) { $this->existingSchemaPaths = array_filter($paths, static function ($v) use ($names) {
return in_array($v, $names); return in_array($v, $names, true);
}); });
} }
......
...@@ -10,7 +10,6 @@ use PDOException; ...@@ -10,7 +10,6 @@ use PDOException;
use Throwable; use Throwable;
use function assert; use function assert;
use function count; use function count;
use function in_array;
use function is_string; use function is_string;
use function preg_match; use function preg_match;
use function sprintf; use function sprintf;
...@@ -104,7 +103,6 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -104,7 +103,6 @@ class SQLServerSchemaManager extends AbstractSchemaManager
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type); $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
$options = [ $options = [
'length' => $length === 0 || ! in_array($type, ['text', 'string']) ? null : $length,
'unsigned' => false, 'unsigned' => false,
'fixed' => (bool) $fixed, 'fixed' => (bool) $fixed,
'default' => $default, 'default' => $default,
...@@ -115,6 +113,10 @@ class SQLServerSchemaManager extends AbstractSchemaManager ...@@ -115,6 +113,10 @@ class SQLServerSchemaManager extends AbstractSchemaManager
'comment' => $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null, 'comment' => $tableColumn['comment'] !== '' ? $tableColumn['comment'] : null,
]; ];
if ($length !== 0 && ($type === 'text' || $type === 'string')) {
$options['length'] = $length;
}
$column = new Column($tableColumn['name'], Type::getType($type), $options); $column = new Column($tableColumn['name'], Type::getType($type), $options);
if (isset($tableColumn['collation']) && $tableColumn['collation'] !== 'NULL') { if (isset($tableColumn['collation']) && $tableColumn['collation'] !== 'NULL') {
......
...@@ -84,7 +84,7 @@ class Graphviz extends AbstractVisitor ...@@ -84,7 +84,7 @@ class Graphviz extends AbstractVisitor
$primaryKey = $table->getPrimaryKey(); $primaryKey = $table->getPrimaryKey();
if ($primaryKey !== null && in_array($column->getName(), $primaryKey->getColumns())) { if ($primaryKey !== null && in_array($column->getName(), $primaryKey->getColumns(), true)) {
$label .= "\xe2\x9c\xb7"; $label .= "\xe2\x9c\xb7";
} }
$label .= '</TD></TR>'; $label .= '</TD></TR>';
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
namespace Doctrine\DBAL\Tests\Functional\Platform; namespace Doctrine\DBAL\Tests\Functional\Platform;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function in_array;
final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends FunctionalTestCase final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends FunctionalTestCase
{ {
...@@ -16,7 +16,7 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends FunctionalTestCa ...@@ -16,7 +16,7 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends FunctionalTestCa
{ {
parent::setUp(); parent::setUp();
if (in_array($this->getPlatform()->getName(), ['mysql'])) { if ($this->getPlatform() instanceof MySqlPlatform) {
return; return;
} }
......
...@@ -220,7 +220,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -220,7 +220,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$namespaces = $this->schemaManager->listNamespaceNames(); $namespaces = $this->schemaManager->listNamespaceNames();
$namespaces = array_map('strtolower', $namespaces); $namespaces = array_map('strtolower', $namespaces);
if (! in_array('test_create_schema', $namespaces)) { if (! in_array('test_create_schema', $namespaces, true)) {
$this->connection->executeUpdate($this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema')); $this->connection->executeUpdate($this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema'));
$namespaces = $this->schemaManager->listNamespaceNames(); $namespaces = $this->schemaManager->listNamespaceNames();
......
...@@ -4,9 +4,9 @@ namespace Doctrine\DBAL\Tests\Functional\Ticket; ...@@ -4,9 +4,9 @@ namespace Doctrine\DBAL\Tests\Functional\Ticket;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use PDO; use PDO;
use function in_array;
/** /**
* @group DBAL-630 * @group DBAL-630
...@@ -20,9 +20,7 @@ class DBAL630Test extends FunctionalTestCase ...@@ -20,9 +20,7 @@ class DBAL630Test extends FunctionalTestCase
{ {
parent::setUp(); parent::setUp();
$platform = $this->connection->getDatabasePlatform()->getName(); if (! $this->connection->getDatabasePlatform() instanceof PostgreSQL94Platform) {
if (! in_array($platform, ['postgresql'])) {
self::markTestSkipped('Currently restricted to PostgreSQL'); self::markTestSkipped('Currently restricted to PostgreSQL');
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
namespace Doctrine\DBAL\Tests\Functional\Ticket; namespace Doctrine\DBAL\Tests\Functional\Ticket;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Tests\FunctionalTestCase;
use function in_array;
/** /**
* @group DBAL-752 * @group DBAL-752
...@@ -14,9 +14,7 @@ class DBAL752Test extends FunctionalTestCase ...@@ -14,9 +14,7 @@ class DBAL752Test extends FunctionalTestCase
{ {
parent::setUp(); parent::setUp();
$platform = $this->connection->getDatabasePlatform()->getName(); if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
if (in_array($platform, ['sqlite'])) {
return; return;
} }
......
...@@ -93,7 +93,7 @@ final class DB2SchemaManagerTest extends TestCase ...@@ -93,7 +93,7 @@ final class DB2SchemaManagerTest extends TestCase
{ {
$accepted = ['T_FOO', 'T_BAR']; $accepted = ['T_FOO', 'T_BAR'];
$this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) { $this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) {
return in_array($assetName, $accepted); return in_array($assetName, $accepted, true);
}); });
$this->conn->expects(self::any())->method('quote'); $this->conn->expects(self::any())->method('quote');
$this->conn->expects(self::once())->method('fetchAll')->will(self::returnValue([ $this->conn->expects(self::once())->method('fetchAll')->will(self::returnValue([
......
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