Skip to content

Commit

Permalink
Fixed some more code style
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Jan 29, 2018
1 parent 0551c5e commit 97ef0b0
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 170 deletions.
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/Driver/ResultStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function columnCount();
/**
* Sets the fetch mode to use while iterating this statement.
*
* @param integer $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
* @param mixed $arg2
* @param mixed $arg3
* @param int $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
* @param mixed $arg2
* @param mixed $arg3
*
* @return boolean
*/
Expand Down
30 changes: 15 additions & 15 deletions lib/Doctrine/DBAL/Driver/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ interface Statement extends ResultStatement
* As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
* fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
*
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed $value The value to bind to the parameter.
* @param integer $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
* constants.
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement
* using question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed $value The value to bind to the parameter.
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
* constants.
*
* @return boolean TRUE on success or FALSE on failure.
*/
Expand All @@ -66,15 +66,15 @@ public function bindValue($param, $value, $type = ParameterType::STRING);
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
* @param mixed $column Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement using
* question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
* @param integer|null $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
* constants. To return an INOUT parameter from a stored procedure, use the bitwise
* OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
* @param integer|null $length You must specify maxlength when using an OUT bind
* so that PHP allocates enough memory to hold the returned value.
* @param mixed $column Parameter identifier. For a prepared statement using named placeholders,
* this will be a parameter name of the form :name. For a prepared statement using
* question mark placeholders, this will be the 1-indexed position of the parameter.
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
* @param int|null $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
* constants. To return an INOUT parameter from a stored procedure, use the bitwise
* OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
* @param int|null $length You must specify maxlength when using an OUT bind
* so that PHP allocates enough memory to hold the returned value.
*
* @return boolean TRUE on success or FALSE on failure.
*/
Expand Down
12 changes: 7 additions & 5 deletions lib/Doctrine/DBAL/Id/TableGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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.
Expand Down Expand Up @@ -120,12 +121,13 @@ public function nextValue($sequenceName)

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'];
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Portability/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function connect()
// 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;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/DBAL/Portability/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
$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);
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ public function getSQL()
* ->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.
*/
Expand Down
16 changes: 12 additions & 4 deletions tests/Doctrine/Tests/DBAL/Functional/BlobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ protected function setUp()

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);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ public function testTransactionalReturnValue()
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)
);
}

Expand Down
46 changes: 19 additions & 27 deletions tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ public function testFetchAllWithTypes()
$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);

Expand Down Expand Up @@ -226,8 +226,8 @@ public function testFetchAllWithMissingTypes()

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);

Expand Down Expand Up @@ -264,8 +264,8 @@ public function testFetchAssocWithTypes()
$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);

Expand Down Expand Up @@ -305,8 +305,8 @@ public function testFetchArrayWithTypes()
$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);

Expand Down Expand Up @@ -350,13 +350,8 @@ public function testFetchColumnWithTypes()
$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);

Expand Down Expand Up @@ -401,18 +396,15 @@ public function testExecuteUpdateBindDateTimeType()
$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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testConnectsWithValidCharsetOption($charset)

self::assertEquals(
$charset,
$connection->query("SHOW client_encoding")
$connection->query('SHOW client_encoding')
->fetch(FetchMode::COLUMN)
);
}
Expand Down
Loading

0 comments on commit 97ef0b0

Please sign in to comment.