Skip to content

Commit 4190669

Browse files
committed
Fixed some more code style
1 parent 0e99c34 commit 4190669

File tree

9 files changed

+192
-152
lines changed

9 files changed

+192
-152
lines changed

lib/Doctrine/DBAL/Id/TableGenerator.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Doctrine\DBAL\DriverManager;
2323
use Doctrine\DBAL\Connection;
2424
use Doctrine\DBAL\FetchMode;
25+
use Doctrine\DBAL\LockMode;
2526

2627
/**
2728
* Table ID Generator for those poor languages that are missing sequences.
@@ -120,12 +121,13 @@ public function nextValue($sequenceName)
120121

121122
try {
122123
$platform = $this->conn->getDatabasePlatform();
123-
$sql = "SELECT sequence_value, sequence_increment_by " .
124-
"FROM " . $platform->appendLockHint($this->generatorTableName, \Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE) . " " .
125-
"WHERE sequence_name = ? " . $platform->getWriteLockSQL();
126-
$stmt = $this->conn->executeQuery($sql, [$sequenceName]);
124+
$sql = 'SELECT sequence_value, sequence_increment_by'
125+
. ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE)
126+
. ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL();
127+
$stmt = $this->conn->executeQuery($sql, [$sequenceName]);
128+
$row = $stmt->fetch(FetchMode::ASSOCIATIVE);
127129

128-
if ($row = $stmt->fetch(FetchMode::ASSOCIATIVE)) {
130+
if ($row !== false) {
129131
$row = array_change_key_case($row, CASE_LOWER);
130132

131133
$value = $row['sequence_value'];

lib/Doctrine/DBAL/Portability/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function connect()
9090
// make use of c-level support for case handling
9191
$this->_conn->setAttribute(\PDO::ATTR_CASE, $params['fetch_case']);
9292
} else {
93-
$this->case = ($params['fetch_case'] == ColumnCase::LOWER) ? CASE_LOWER : CASE_UPPER;
93+
$this->case = ($params['fetch_case'] === ColumnCase::LOWER) ? CASE_LOWER : CASE_UPPER;
9494
}
9595
}
9696
}

lib/Doctrine/DBAL/Portability/Statement.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
150150
$row = $this->stmt->fetch($fetchMode);
151151

152152
$iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM);
153-
$fixCase = ! is_null($this->case) && ($fetchMode == FetchMode::ASSOCIATIVE || $fetchMode == FetchMode::MIXED)
153+
$fixCase = ! is_null($this->case)
154+
&& ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED)
154155
&& ($this->portability & Connection::PORTABILITY_FIX_CASE);
155156

156157
$row = $this->fixRow($row, $iterateRow, $fixCase);

lib/Doctrine/DBAL/Query/QueryBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ public function getSQL()
263263
* ->setParameter(':user_id', 1);
264264
* </code>
265265
*
266-
* @param string|integer $key The parameter position or name.
267-
* @param mixed $value The parameter value.
268-
* @param string|integer|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants.
266+
* @param string|int $key The parameter position or name.
267+
* @param mixed $value The parameter value.
268+
* @param string|int|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants.
269269
*
270270
* @return $this This QueryBuilder instance.
271271
*/

tests/Doctrine/Tests/DBAL/Functional/BlobTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,18 @@ protected function setUp()
3737

3838
public function testInsert()
3939
{
40-
$ret = $this->_conn->insert('blob_table',
41-
array('id' => 1, 'clobfield' => 'test', 'blobfield' => 'test', 'binaryfield' => 'test'),
42-
array(ParameterType::INTEGER, ParameterType::STRING, ParameterType::LARGE_OBJECT, ParameterType::LARGE_OBJECT)
43-
);
40+
$ret = $this->_conn->insert('blob_table', [
41+
'id' => 1,
42+
'clobfield' => 'test',
43+
'blobfield' => 'test',
44+
'binaryfield' => 'test',
45+
], [
46+
ParameterType::INTEGER,
47+
ParameterType::STRING,
48+
ParameterType::LARGE_OBJECT,
49+
ParameterType::LARGE_OBJECT,
50+
]);
51+
4452
self::assertEquals(1, $ret);
4553
}
4654

tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ public function testTransactionalReturnValue()
244244
public function testQuote()
245245
{
246246
self::assertEquals(
247-
$this->_conn->quote("foo", Type::STRING),
248-
$this->_conn->quote("foo", ParameterType::STRING)
247+
$this->_conn->quote('foo', Type::STRING),
248+
$this->_conn->quote('foo', ParameterType::STRING)
249249
);
250250
}
251251

tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ public function testFetchAllWithTypes()
195195
$datetimeString = '2010-01-01 10:10:10';
196196
$datetime = new \DateTime($datetimeString);
197197

198-
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
199-
$data = $this->_conn->fetchAll($sql, array(1, $datetime), array(ParameterType::STRING, Type::DATETIME));
198+
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
199+
$data = $this->_conn->fetchAll($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
200200

201201
self::assertCount(1, $data);
202202

@@ -227,8 +227,8 @@ public function testFetchAllWithMissingTypes()
227227

228228
public function testFetchBoth()
229229
{
230-
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
231-
$row = $this->_conn->executeQuery($sql, array(1, 'foo'))->fetch(FetchMode::MIXED);
230+
$sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?';
231+
$row = $this->_conn->executeQuery($sql, [1, 'foo'])->fetch(FetchMode::MIXED);
232232

233233
self::assertNotFalse($row);
234234

@@ -265,8 +265,8 @@ public function testFetchAssocWithTypes()
265265
$datetimeString = '2010-01-01 10:10:10';
266266
$datetime = new \DateTime($datetimeString);
267267

268-
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
269-
$row = $this->_conn->fetchAssoc($sql, array(1, $datetime), array(ParameterType::STRING, Type::DATETIME));
268+
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
269+
$row = $this->_conn->fetchAssoc($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
270270

271271
self::assertNotFalse($row);
272272

@@ -306,8 +306,8 @@ public function testFetchArrayWithTypes()
306306
$datetimeString = '2010-01-01 10:10:10';
307307
$datetime = new \DateTime($datetimeString);
308308

309-
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
310-
$row = $this->_conn->fetchArray($sql, array(1, $datetime), array(ParameterType::STRING, Type::DATETIME));
309+
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
310+
$row = $this->_conn->fetchArray($sql, [1, $datetime], [ParameterType::STRING, Type::DATETIME]);
311311

312312
self::assertNotFalse($row);
313313

@@ -351,13 +351,8 @@ public function testFetchColumnWithTypes()
351351
$datetimeString = '2010-01-01 10:10:10';
352352
$datetime = new \DateTime($datetimeString);
353353

354-
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
355-
$column = $this->_conn->fetchColumn(
356-
$sql,
357-
array(1, $datetime),
358-
1,
359-
array(ParameterType::STRING, Type::DATETIME)
360-
);
354+
$sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?';
355+
$column = $this->_conn->fetchColumn($sql, [1, $datetime], 1, [ParameterType::STRING, Type::DATETIME]);
361356

362357
self::assertNotFalse($column);
363358

@@ -402,18 +397,15 @@ public function testExecuteUpdateBindDateTimeType()
402397
$datetime = new \DateTime('2010-02-02 20:20:20');
403398

404399
$sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)';
405-
$affectedRows = $this->_conn->executeUpdate($sql,
406-
array(
407-
1 => 50,
408-
2 => 'foo',
409-
3 => $datetime,
410-
),
411-
array(
412-
1 => ParameterType::INTEGER,
413-
2 => ParameterType::STRING,
414-
3 => Type::DATETIME,
415-
)
416-
);
400+
$affectedRows = $this->_conn->executeUpdate($sql, [
401+
1 => 50,
402+
2 => 'foo',
403+
3 => $datetime,
404+
], [
405+
1 => ParameterType::INTEGER,
406+
2 => ParameterType::STRING,
407+
3 => Type::DATETIME,
408+
]);
417409

418410
self::assertEquals(1, $affectedRows);
419411
self::assertEquals(1, $this->_conn->executeQuery(

tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testConnectsWithValidCharsetOption($charset)
4343

4444
self::assertEquals(
4545
$charset,
46-
$connection->query("SHOW client_encoding")
46+
$connection->query('SHOW client_encoding')
4747
->fetch(FetchMode::COLUMN)
4848
);
4949
}

0 commit comments

Comments
 (0)