Fixed some more code style

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