Use in_array() in strict mode

parent 182d3d8f
......@@ -195,7 +195,7 @@ final class DriverManager
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']);
}
}
......
......@@ -494,7 +494,7 @@ abstract class AbstractPlatform
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
$columnData['length'] = 255;
}
if (in_array($column->getName(), $options['primary'])) {
if (in_array($column->getName(), $options['primary'], true)) {
$columnData['primary'] = true;
}
......
......@@ -765,7 +765,7 @@ SQL
$column = $diff->fromTable->getColumn($columnName);
// 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;
}
......
......@@ -40,7 +40,7 @@ class ColumnDiff
*/
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;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use function array_keys;
use function array_map;
use function in_array;
use function strrpos;
use function strtolower;
use function strtoupper;
......@@ -360,7 +359,7 @@ class ForeignKeyConstraint extends AbstractAsset implements Constraint
if (isset($this->_options[$event])) {
$onEvent = strtoupper($this->_options[$event]);
if (! in_array($onEvent, ['NO ACTION', 'RESTRICT'])) {
if ($onEvent !== 'NO ACTION' && $onEvent !== 'RESTRICT') {
return $onEvent;
}
}
......
......@@ -94,7 +94,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$paths = $this->getSchemaSearchPaths();
$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;
use Throwable;
use function assert;
use function count;
use function in_array;
use function is_string;
use function preg_match;
use function sprintf;
......@@ -104,7 +103,6 @@ class SQLServerSchemaManager extends AbstractSchemaManager
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
$options = [
'length' => $length === 0 || ! in_array($type, ['text', 'string']) ? null : $length,
'unsigned' => false,
'fixed' => (bool) $fixed,
'default' => $default,
......@@ -115,6 +113,10 @@ class SQLServerSchemaManager extends AbstractSchemaManager
'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);
if (isset($tableColumn['collation']) && $tableColumn['collation'] !== 'NULL') {
......
......@@ -84,7 +84,7 @@ class Graphviz extends AbstractVisitor
$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 .= '</TD></TR>';
......
......@@ -3,9 +3,9 @@
namespace Doctrine\DBAL\Tests\Functional\Platform;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use function in_array;
final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends FunctionalTestCase
{
......@@ -16,7 +16,7 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends FunctionalTestCa
{
parent::setUp();
if (in_array($this->getPlatform()->getName(), ['mysql'])) {
if ($this->getPlatform() instanceof MySqlPlatform) {
return;
}
......
......@@ -220,7 +220,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$namespaces = $this->schemaManager->listNamespaceNames();
$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'));
$namespaces = $this->schemaManager->listNamespaceNames();
......
......@@ -4,9 +4,9 @@ namespace Doctrine\DBAL\Tests\Functional\Ticket;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use PDO;
use function in_array;
/**
* @group DBAL-630
......@@ -20,9 +20,7 @@ class DBAL630Test extends FunctionalTestCase
{
parent::setUp();
$platform = $this->connection->getDatabasePlatform()->getName();
if (! in_array($platform, ['postgresql'])) {
if (! $this->connection->getDatabasePlatform() instanceof PostgreSQL94Platform) {
self::markTestSkipped('Currently restricted to PostgreSQL');
}
......
......@@ -2,8 +2,8 @@
namespace Doctrine\DBAL\Tests\Functional\Ticket;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Tests\FunctionalTestCase;
use function in_array;
/**
* @group DBAL-752
......@@ -14,9 +14,7 @@ class DBAL752Test extends FunctionalTestCase
{
parent::setUp();
$platform = $this->connection->getDatabasePlatform()->getName();
if (in_array($platform, ['sqlite'])) {
if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
return;
}
......
......@@ -93,7 +93,7 @@ final class DB2SchemaManagerTest extends TestCase
{
$accepted = ['T_FOO', 'T_BAR'];
$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::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