Commit 15aa7908 authored by Vladimir Reznichenko's avatar Vladimir Reznichenko

Php Inspections (EA Ultimate): minor code tweaks

parent 402bbcf0
......@@ -113,7 +113,7 @@ class MasterSlaveConnection extends Connection
*/
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');
}
if (count($params['slaves']) == 0) {
......
......@@ -215,7 +215,7 @@ class DB2Statement implements \IteratorAggregate, Statement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
$this->_defaultFetchMode = $fetchMode;
$this->defaultFetchClass = $arg2 ? $arg2 : $this->defaultFetchClass;
$this->defaultFetchClass = $arg2 ?: $this->defaultFetchClass;
$this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs;
return true;
......
......@@ -19,7 +19,7 @@
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\ServerInfoAwareConnection;
use Doctrine\DBAL\ParameterType;
......
......@@ -59,7 +59,7 @@ class Driver extends AbstractPostgreSQLDriver
* - passing client_encoding via the 'options' param breaks pgbouncer support
*/
if (isset($params['charset'])) {
$pdo->query('SET NAMES \''.$params['charset'].'\'');
$pdo->exec('SET NAMES \'' . $params['charset'] . '\'');
}
return $pdo;
......
......@@ -336,7 +336,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
$this->defaultFetchMode = $fetchMode;
$this->defaultFetchClass = $arg2 ? $arg2 : $this->defaultFetchClass;
$this->defaultFetchClass = $arg2 ?: $this->defaultFetchClass;
$this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs;
}
......
......@@ -211,7 +211,7 @@ class MySqlPlatform extends AbstractPlatform
" c.constraint_name = k.constraint_name AND ".
" 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.`REFERENCED_COLUMN_NAME` is not NULL";
......
......@@ -829,11 +829,11 @@ class PostgreSqlPlatform extends AbstractPlatform
/**
* 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);
}
if (in_array(trim(strtolower($value)), $this->booleanLiterals['true'], true)) {
if (in_array(strtolower(trim($value)), $this->booleanLiterals['true'], true)) {
return $callback(true);
}
......
......@@ -1127,7 +1127,7 @@ class SQLServerPlatform extends AbstractPlatform
*/
public function getSubstringExpression($value, $from, $length = null)
{
if (!is_null($length)) {
if ($length !== null) {
return 'SUBSTRING(' . $value . ', ' . $from . ', ' . $length . ')';
}
......
......@@ -803,7 +803,7 @@ class SqlitePlatform extends AbstractPlatform
*/
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);
}
......
......@@ -153,7 +153,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
$row = $this->stmt->fetch($fetchMode);
$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)
&& ($this->portability & Connection::PORTABILITY_FIX_CASE);
......@@ -176,7 +176,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
}
$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)
&& ($this->portability & Connection::PORTABILITY_FIX_CASE);
......
......@@ -1085,7 +1085,7 @@ class QueryBuilder
*/
public function resetQueryParts($queryPartNames = null)
{
if (is_null($queryPartNames)) {
if ($queryPartNames === null) {
$queryPartNames = array_keys($this->sqlParts);
}
......
......@@ -232,6 +232,6 @@ abstract class AbstractAsset
return dechex(crc32($column));
}, $columnNames));
return substr(strtoupper($prefix . "_" . $hash), 0, $maxSize);
return strtoupper(substr($prefix . '_' . $hash, 0, $maxSize));
}
}
......@@ -148,7 +148,7 @@ abstract class AbstractSchemaManager
*/
public function listSequences($database = null)
{
if (is_null($database)) {
if ($database === null) {
$database = $this->_conn->getDatabase();
}
$sql = $this->_platform->getListSequencesSQL($database);
......@@ -323,7 +323,7 @@ abstract class AbstractSchemaManager
*/
public function listTableForeignKeys($table, $database = null)
{
if (is_null($database)) {
if ($database === null) {
$database = $this->_conn->getDatabase();
}
$sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
......
......@@ -126,7 +126,7 @@ class OracleSchemaManager extends AbstractSchemaManager
$buffer['non_unique'] = false;
} else {
$buffer['primary'] = false;
$buffer['non_unique'] = ($tableIndex['is_unique'] == 0) ? true : false;
$buffer['non_unique'] = ! $tableIndex['is_unique'];
}
$buffer['key_name'] = $keyName;
$buffer['column_name'] = $this->getQuotedIdentifierName($tableIndex['column_name']);
......@@ -336,7 +336,7 @@ class OracleSchemaManager extends AbstractSchemaManager
*/
public function createDatabase($database = null)
{
if (is_null($database)) {
if ($database === null) {
$database = $this->_conn->getDatabase();
}
......
......@@ -20,6 +20,7 @@
namespace Doctrine\DBAL\Schema;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Types\Type;
use const CASE_LOWER;
......@@ -63,9 +64,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
*/
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
foreach ($tableForeignKeys as $key => $value) {
$id = $value['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]['deferred'] = isset($deferred[$id]) && 'deferred' == strtolower($deferred[$id]) ? true : false;
$tableForeignKeys[$key]['deferrable'] = isset($deferrable[$id]) && strtolower($deferrable[$id]) === 'deferrable';
$tableForeignKeys[$key]['deferred'] = isset($deferred[$id]) && strtolower($deferred[$id]) === 'deferred';
}
}
......
......@@ -93,11 +93,11 @@ class PoolingShardConnection extends Connection
*/
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.");
}
if ( !isset($params['shardChoser'])) {
if (! isset($params['shardChoser'])) {
throw new \InvalidArgumentException("Missing Shard Choser configuration 'shardChoser'");
}
......
......@@ -149,7 +149,6 @@ final class Dumper
$name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private');
}
$return->$name = self::export($clone[$key], $maxDepth - 1);
;
}
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