Skip to content

Commit 97ef0b0

Browse files
committed
Fixed some more code style
1 parent 0551c5e commit 97ef0b0

File tree

11 files changed

+210
-170
lines changed

11 files changed

+210
-170
lines changed

lib/Doctrine/DBAL/Driver/ResultStatement.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public function columnCount();
4545
/**
4646
* Sets the fetch mode to use while iterating this statement.
4747
*
48-
* @param integer $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
49-
* @param mixed $arg2
50-
* @param mixed $arg3
48+
* @param int $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
49+
* @param mixed $arg2
50+
* @param mixed $arg3
5151
*
5252
* @return boolean
5353
*/

lib/Doctrine/DBAL/Driver/Statement.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ interface Statement extends ResultStatement
4141
* As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
4242
* fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
4343
*
44-
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
45-
* this will be a parameter name of the form :name. For a prepared statement
46-
* using question mark placeholders, this will be the 1-indexed position of the parameter.
47-
* @param mixed $value The value to bind to the parameter.
48-
* @param integer $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
49-
* constants.
44+
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
45+
* this will be a parameter name of the form :name. For a prepared statement
46+
* using question mark placeholders, this will be the 1-indexed position of the parameter.
47+
* @param mixed $value The value to bind to the parameter.
48+
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
49+
* constants.
5050
*
5151
* @return boolean TRUE on success or FALSE on failure.
5252
*/
@@ -66,15 +66,15 @@ public function bindValue($param, $value, $type = ParameterType::STRING);
6666
* of stored procedures that return data as output parameters, and some also as input/output
6767
* parameters that both send in data and are updated to receive it.
6868
*
69-
* @param mixed $column Parameter identifier. For a prepared statement using named placeholders,
70-
* this will be a parameter name of the form :name. For a prepared statement using
71-
* question mark placeholders, this will be the 1-indexed position of the parameter.
72-
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
73-
* @param integer|null $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
74-
* constants. To return an INOUT parameter from a stored procedure, use the bitwise
75-
* OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
76-
* @param integer|null $length You must specify maxlength when using an OUT bind
77-
* so that PHP allocates enough memory to hold the returned value.
69+
* @param mixed $column Parameter identifier. For a prepared statement using named placeholders,
70+
* this will be a parameter name of the form :name. For a prepared statement using
71+
* question mark placeholders, this will be the 1-indexed position of the parameter.
72+
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
73+
* @param int|null $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
74+
* constants. To return an INOUT parameter from a stored procedure, use the bitwise
75+
* OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
76+
* @param int|null $length You must specify maxlength when using an OUT bind
77+
* so that PHP allocates enough memory to hold the returned value.
7878
*
7979
* @return boolean TRUE on success or FALSE on failure.
8080
*/

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
@@ -194,8 +194,8 @@ public function testFetchAllWithTypes()
194194
$datetimeString = '2010-01-01 10:10:10';
195195
$datetime = new \DateTime($datetimeString);
196196

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

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

@@ -226,8 +226,8 @@ public function testFetchAllWithMissingTypes()
226226

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

232232
self::assertNotFalse($row);
233233

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

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

270270
self::assertNotFalse($row);
271271

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

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

311311
self::assertNotFalse($row);
312312

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

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

361356
self::assertNotFalse($column);
362357

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

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

417409
self::assertEquals(1, $affectedRows);
418410
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)