Fixed some more code style

parent 0e99c343
......@@ -22,6 +22,7 @@ namespace Doctrine\DBAL\Id;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\LockMode;
/**
* Table ID Generator for those poor languages that are missing sequences.
......@@ -120,12 +121,13 @@ class TableGenerator
try {
$platform = $this->conn->getDatabasePlatform();
$sql = "SELECT sequence_value, sequence_increment_by " .
"FROM " . $platform->appendLockHint($this->generatorTableName, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) . " " .
"WHERE sequence_name = ? " . $platform->getWriteLockSQL();
$stmt = $this->conn->executeQuery($sql, [$sequenceName]);
$sql = 'SELECT sequence_value, sequence_increment_by'
. ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE)
. ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL();
$stmt = $this->conn->executeQuery($sql, [$sequenceName]);
$row = $stmt->fetch(FetchMode::ASSOCIATIVE);
if ($row = $stmt->fetch(FetchMode::ASSOCIATIVE)) {
if ($row !== false) {
$row = array_change_key_case($row, CASE_LOWER);
$value = $row['sequence_value'];
......
......@@ -90,7 +90,7 @@ class Connection extends \Doctrine\DBAL\Connection
// make use of c-level support for case handling
$this->_conn->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']);
} else {
$this->case = ($params['fetch_case'] == ColumnCase::LOWER) ? CASE_LOWER : CASE_UPPER;
$this->case = ($params['fetch_case'] === ColumnCase::LOWER) ? CASE_LOWER : CASE_UPPER;
}
}
}
......
......@@ -150,7 +150,8 @@ 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) && ($fetchMode == FetchMode::ASSOCIATIVE || $fetchMode == FetchMode::MIXED)
$fixCase = ! is_null($this->case)
&& ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED)
&& ($this->portability & Connection::PORTABILITY_FIX_CASE);
$row = $this->fixRow($row, $iterateRow, $fixCase);
......
......@@ -263,9 +263,9 @@ class QueryBuilder
* ->setParameter(':user_id', 1);
* </code>
*
* @param string|integer $key The parameter position or name.
* @param mixed $value The parameter value.
* @param string|integer|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants.
* @param string|int $key The parameter position or name.
* @param mixed $value The parameter value.
* @param string|int|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants.
*
* @return $this This QueryBuilder instance.
*/
......
......@@ -37,10 +37,18 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testInsert()
{
$ret = $this->_conn->insert('blob_table',
array('id' => 1, 'clobfield' => 'test', 'blobfield' => 'test', 'binaryfield' => 'test'),
array(ParameterType::INTEGER, ParameterType::STRING, ParameterType::LARGE_OBJECT, ParameterType::LARGE_OBJECT)
);
$ret = $this->_conn->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
'binaryfield' => 'test',
], [
ParameterType::INTEGER,
ParameterType::STRING,
ParameterType::LARGE_OBJECT,
ParameterType::LARGE_OBJECT,
]);
self::assertEquals(1, $ret);
}
......
......@@ -244,8 +244,8 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testQuote()
{
self::assertEquals(
$this->_conn->quote("foo", Type::STRING),
$this->_conn->quote("foo", ParameterType::STRING)
$this->_conn->quote('foo', Type::STRING),
$this->_conn->quote('foo', ParameterType::STRING)
);
}
......
......@@ -195,8 +195,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$data = $this->_conn->fetchAll($sql, array(1, $datetime), array(ParameterType::STRING, Type::DATETIME));
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
$data = $this->_conn->fetchAll($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
self::assertCount(1, $data);
......@@ -227,8 +227,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testFetchBoth()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$row = $this->_conn->executeQuery($sql, array(1, 'foo'))->fetch(FetchMode::MIXED);
$sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
$row = $this->_conn->executeQuery($sql, [1, 'foo'])->fetch(FetchMode::MIXED);
self::assertNotFalse($row);
......@@ -265,8 +265,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$row = $this->_conn->fetchAssoc($sql, array(1, $datetime), array(ParameterType::STRING, Type::DATETIME));
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
$row = $this->_conn->fetchAssoc($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
self::assertNotFalse($row);
......@@ -306,8 +306,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$row = $this->_conn->fetchArray($sql, array(1, $datetime), array(ParameterType::STRING, Type::DATETIME));
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
$row = $this->_conn->fetchArray($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
self::assertNotFalse($row);
......@@ -351,13 +351,8 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$column = $this->_conn->fetchColumn(
$sql,
array(1, $datetime),
1,
array(ParameterType::STRING, Type::DATETIME)
);
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
$column = $this->_conn->fetchColumn($sql, [1, $datetime], 1, [ParameterType::STRING, Type::DATETIME]);
self::assertNotFalse($column);
......@@ -402,18 +397,15 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$datetime = new \DateTime('2010-02-02 20:20:20');
$sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)';
$affectedRows = $this->_conn->executeUpdate($sql,
array(
1 => 50,
2 => 'foo',
3 => $datetime,
),
array(
1 => ParameterType::INTEGER,
2 => ParameterType::STRING,
3 => Type::DATETIME,
)
);
$affectedRows = $this->_conn->executeUpdate($sql, [
1 => 50,
2 => 'foo',
3 => $datetime,
], [
1 => ParameterType::INTEGER,
2 => ParameterType::STRING,
3 => Type::DATETIME,
]);
self::assertEquals(1, $affectedRows);
self::assertEquals(1, $this->_conn->executeQuery(
......
......@@ -43,7 +43,7 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase
self::assertEquals(
$charset,
$connection->query("SHOW client_encoding")
$connection->query('SHOW client_encoding')
->fetch(FetchMode::COLUMN)
);
}
......
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