Unverified Commit 29f17994 authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub

Merge pull request #3200 from kalessil/master

[minor] SCA
parents 402bbcf0 15aa7908
...@@ -113,7 +113,7 @@ class MasterSlaveConnection extends Connection ...@@ -113,7 +113,7 @@ class MasterSlaveConnection extends Connection
*/ */
public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
{ {
if ( !isset($params['slaves']) || !isset($params['master'])) { if (! isset($params['slaves'], $params['master'])) {
throw new \InvalidArgumentException('master or slaves configuration missing'); throw new \InvalidArgumentException('master or slaves configuration missing');
} }
if (count($params['slaves']) == 0) { if (count($params['slaves']) == 0) {
......
...@@ -215,7 +215,7 @@ class DB2Statement implements \IteratorAggregate, Statement ...@@ -215,7 +215,7 @@ class DB2Statement implements \IteratorAggregate, Statement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
$this->_defaultFetchMode = $fetchMode; $this->_defaultFetchMode = $fetchMode;
$this->defaultFetchClass = $arg2 ? $arg2 : $this->defaultFetchClass; $this->defaultFetchClass = $arg2 ?: $this->defaultFetchClass;
$this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs; $this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs;
return true; return true;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
namespace Doctrine\DBAL\Driver\Mysqli; namespace Doctrine\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver\Connection as Connection; use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\PingableConnection; use Doctrine\DBAL\Driver\PingableConnection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
......
...@@ -59,7 +59,7 @@ class Driver extends AbstractPostgreSQLDriver ...@@ -59,7 +59,7 @@ class Driver extends AbstractPostgreSQLDriver
* - passing client_encoding via the 'options' param breaks pgbouncer support * - passing client_encoding via the 'options' param breaks pgbouncer support
*/ */
if (isset($params['charset'])) { if (isset($params['charset'])) {
$pdo->query('SET NAMES \''.$params['charset'].'\''); $pdo->exec('SET NAMES \'' . $params['charset'] . '\'');
} }
return $pdo; return $pdo;
......
...@@ -336,7 +336,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -336,7 +336,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{ {
$this->defaultFetchMode = $fetchMode; $this->defaultFetchMode = $fetchMode;
$this->defaultFetchClass = $arg2 ? $arg2 : $this->defaultFetchClass; $this->defaultFetchClass = $arg2 ?: $this->defaultFetchClass;
$this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs; $this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs;
} }
......
...@@ -211,7 +211,7 @@ class MySqlPlatform extends AbstractPlatform ...@@ -211,7 +211,7 @@ class MySqlPlatform extends AbstractPlatform
" c.constraint_name = k.constraint_name AND ". " c.constraint_name = k.constraint_name AND ".
" c.table_name = $table */ WHERE k.table_name = $table"; " c.table_name = $table */ WHERE k.table_name = $table";
$databaseNameSql = null === $database ? 'DATABASE()' : $database; $databaseNameSql = $database ?? 'DATABASE()';
$sql .= " AND k.table_schema = $databaseNameSql /*!50116 AND c.constraint_schema = $databaseNameSql */"; $sql .= " AND k.table_schema = $databaseNameSql /*!50116 AND c.constraint_schema = $databaseNameSql */";
$sql .= " AND k.`REFERENCED_COLUMN_NAME` is not NULL"; $sql .= " AND k.`REFERENCED_COLUMN_NAME` is not NULL";
......
...@@ -829,11 +829,11 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -829,11 +829,11 @@ class PostgreSqlPlatform extends AbstractPlatform
/** /**
* Better safe than sorry: http://php.net/in_array#106319 * Better safe than sorry: http://php.net/in_array#106319
*/ */
if (in_array(trim(strtolower($value)), $this->booleanLiterals['false'], true)) { if (in_array(strtolower(trim($value)), $this->booleanLiterals['false'], true)) {
return $callback(false); return $callback(false);
} }
if (in_array(trim(strtolower($value)), $this->booleanLiterals['true'], true)) { if (in_array(strtolower(trim($value)), $this->booleanLiterals['true'], true)) {
return $callback(true); return $callback(true);
} }
......
...@@ -1127,7 +1127,7 @@ class SQLServerPlatform extends AbstractPlatform ...@@ -1127,7 +1127,7 @@ class SQLServerPlatform extends AbstractPlatform
*/ */
public function getSubstringExpression($value, $from, $length = null) public function getSubstringExpression($value, $from, $length = null)
{ {
if (!is_null($length)) { if ($length !== null) {
return 'SUBSTRING(' . $value . ', ' . $from . ', ' . $length . ')'; return 'SUBSTRING(' . $value . ', ' . $from . ', ' . $length . ')';
} }
......
...@@ -803,7 +803,7 @@ class SqlitePlatform extends AbstractPlatform ...@@ -803,7 +803,7 @@ class SqlitePlatform extends AbstractPlatform
*/ */
public function getCreateTableSQL(Table $table, $createFlags = null) public function getCreateTableSQL(Table $table, $createFlags = null)
{ {
$createFlags = null === $createFlags ? self::CREATE_INDEXES | self::CREATE_FOREIGNKEYS : $createFlags; $createFlags = $createFlags ?? self::CREATE_INDEXES | self::CREATE_FOREIGNKEYS;
return parent::getCreateTableSQL($table, $createFlags); return parent::getCreateTableSQL($table, $createFlags);
} }
......
...@@ -153,7 +153,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -153,7 +153,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
$row = $this->stmt->fetch($fetchMode); $row = $this->stmt->fetch($fetchMode);
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM);
$fixCase = ! is_null($this->case) $fixCase = $this->case !== null
&& ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED)
&& ($this->portability & Connection::PORTABILITY_FIX_CASE); && ($this->portability & Connection::PORTABILITY_FIX_CASE);
...@@ -176,7 +176,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement ...@@ -176,7 +176,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
} }
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM);
$fixCase = ! is_null($this->case) $fixCase = $this->case !== null
&& ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED)
&& ($this->portability & Connection::PORTABILITY_FIX_CASE); && ($this->portability & Connection::PORTABILITY_FIX_CASE);
......
...@@ -1085,7 +1085,7 @@ class QueryBuilder ...@@ -1085,7 +1085,7 @@ class QueryBuilder
*/ */
public function resetQueryParts($queryPartNames = null) public function resetQueryParts($queryPartNames = null)
{ {
if (is_null($queryPartNames)) { if ($queryPartNames === null) {
$queryPartNames = array_keys($this->sqlParts); $queryPartNames = array_keys($this->sqlParts);
} }
......
...@@ -232,6 +232,6 @@ abstract class AbstractAsset ...@@ -232,6 +232,6 @@ abstract class AbstractAsset
return dechex(crc32($column)); return dechex(crc32($column));
}, $columnNames)); }, $columnNames));
return substr(strtoupper($prefix . "_" . $hash), 0, $maxSize); return strtoupper(substr($prefix . '_' . $hash, 0, $maxSize));
} }
} }
...@@ -148,7 +148,7 @@ abstract class AbstractSchemaManager ...@@ -148,7 +148,7 @@ abstract class AbstractSchemaManager
*/ */
public function listSequences($database = null) public function listSequences($database = null)
{ {
if (is_null($database)) { if ($database === null) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListSequencesSQL($database); $sql = $this->_platform->getListSequencesSQL($database);
...@@ -323,7 +323,7 @@ abstract class AbstractSchemaManager ...@@ -323,7 +323,7 @@ abstract class AbstractSchemaManager
*/ */
public function listTableForeignKeys($table, $database = null) public function listTableForeignKeys($table, $database = null)
{ {
if (is_null($database)) { if ($database === null) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
$sql = $this->_platform->getListTableForeignKeysSQL($table, $database); $sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
......
...@@ -126,7 +126,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -126,7 +126,7 @@ class OracleSchemaManager extends AbstractSchemaManager
$buffer['non_unique'] = false; $buffer['non_unique'] = false;
} else { } else {
$buffer['primary'] = false; $buffer['primary'] = false;
$buffer['non_unique'] = ($tableIndex['is_unique'] == 0) ? true : false; $buffer['non_unique'] = ! $tableIndex['is_unique'];
} }
$buffer['key_name'] = $keyName; $buffer['key_name'] = $keyName;
$buffer['column_name'] = $this->getQuotedIdentifierName($tableIndex['column_name']); $buffer['column_name'] = $this->getQuotedIdentifierName($tableIndex['column_name']);
...@@ -336,7 +336,7 @@ class OracleSchemaManager extends AbstractSchemaManager ...@@ -336,7 +336,7 @@ class OracleSchemaManager extends AbstractSchemaManager
*/ */
public function createDatabase($database = null) public function createDatabase($database = null)
{ {
if (is_null($database)) { if ($database === null) {
$database = $this->_conn->getDatabase(); $database = $this->_conn->getDatabase();
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
namespace Doctrine\DBAL\Schema; namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use const CASE_LOWER; use const CASE_LOWER;
...@@ -63,9 +64,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager ...@@ -63,9 +64,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
*/ */
public function getSchemaNames() public function getSchemaNames()
{ {
$rows = $this->_conn->fetchAll("SELECT nspname as schema_name FROM pg_namespace WHERE nspname !~ '^pg_.*' and nspname != 'information_schema'"); $statement = $this->_conn->executeQuery("SELECT nspname FROM pg_namespace WHERE nspname !~ '^pg_.*' AND nspname != 'information_schema'");
return array_map(function ($v) { return $v['schema_name']; }, $rows); return $statement->fetchAll(FetchMode::COLUMN);
} }
/** /**
......
...@@ -161,8 +161,8 @@ class SqliteSchemaManager extends AbstractSchemaManager ...@@ -161,8 +161,8 @@ class SqliteSchemaManager extends AbstractSchemaManager
foreach ($tableForeignKeys as $key => $value) { foreach ($tableForeignKeys as $key => $value) {
$id = $value['id']; $id = $value['id'];
$tableForeignKeys[$key]['constraint_name'] = isset($names[$id]) && '' != $names[$id] ? $names[$id] : $id; $tableForeignKeys[$key]['constraint_name'] = isset($names[$id]) && '' != $names[$id] ? $names[$id] : $id;
$tableForeignKeys[$key]['deferrable'] = isset($deferrable[$id]) && 'deferrable' == strtolower($deferrable[$id]) ? true : false; $tableForeignKeys[$key]['deferrable'] = isset($deferrable[$id]) && strtolower($deferrable[$id]) === 'deferrable';
$tableForeignKeys[$key]['deferred'] = isset($deferred[$id]) && 'deferred' == strtolower($deferred[$id]) ? true : false; $tableForeignKeys[$key]['deferred'] = isset($deferred[$id]) && strtolower($deferred[$id]) === 'deferred';
} }
} }
......
...@@ -93,11 +93,11 @@ class PoolingShardConnection extends Connection ...@@ -93,11 +93,11 @@ class PoolingShardConnection extends Connection
*/ */
public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null) public function __construct(array $params, Driver $driver, Configuration $config = null, EventManager $eventManager = null)
{ {
if ( !isset($params['global']) || !isset($params['shards'])) { if (! isset($params['global'], $params['shards'])) {
throw new \InvalidArgumentException("Connection Parameters require 'global' and 'shards' configurations."); throw new \InvalidArgumentException("Connection Parameters require 'global' and 'shards' configurations.");
} }
if ( !isset($params['shardChoser'])) { if (! isset($params['shardChoser'])) {
throw new \InvalidArgumentException("Missing Shard Choser configuration 'shardChoser'"); throw new \InvalidArgumentException("Missing Shard Choser configuration 'shardChoser'");
} }
......
...@@ -149,7 +149,6 @@ final class Dumper ...@@ -149,7 +149,6 @@ final class Dumper
$name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private'); $name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private');
} }
$return->$name = self::export($clone[$key], $maxDepth - 1); $return->$name = self::export($clone[$key], $maxDepth - 1);
;
} }
return $return; return $return;
......
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