Skip to content

Commit

Permalink
Type-hint Connection methods
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Oct 31, 2018
1 parent 6050d05 commit 5da6be5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 21 deletions.
8 changes: 4 additions & 4 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,12 +814,12 @@ public function quoteIdentifier($str)
/**
* Quotes a given input parameter.
*
* @param mixed $input The parameter to be quoted.
* @param int|null $type The type of the parameter.
* @param mixed $input The parameter to be quoted.
* @param int $type The type of the parameter.
*
* @return string The quoted parameter.
*/
public function quote($input, $type = null)
public function quote($input, $type = ParameterType::STRING) : string
{
$this->connect();

Expand Down Expand Up @@ -1110,7 +1110,7 @@ public function errorInfo()
*
* @return string A string representation of the last inserted ID.
*/
public function lastInsertId($seqName = null)
public function lastInsertId(string $seqName = null) : string
{
$this->connect();

Expand Down
8 changes: 5 additions & 3 deletions lib/Doctrine/DBAL/Driver/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ public function query(string $sql) : ResultStatement;
/**
* Quotes a string for use in a query.
*
* If the driver does not support quoting, an exception is thrown.
*
* @param mixed $input
* @param int $type
*
* @return mixed
* @return string
*/
public function quote($input, $type = ParameterType::STRING);
public function quote($input, $type = ParameterType::STRING) : string;

/**
* Executes an SQL statement and return the number of affected rows.
Expand All @@ -49,7 +51,7 @@ public function exec(string $statement) : int;
*
* @return string
*/
public function lastInsertId($name = null);
public function lastInsertId(string $name = null) : string;

/**
* Initiates a transaction.
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function query(string $sql) : ResultStatement
/**
* {@inheritdoc}
*/
public function quote($input, $type = ParameterType::STRING)
public function quote($input, $type = ParameterType::STRING) : string
{
$input = db2_escape_string($input);

Expand Down Expand Up @@ -126,7 +126,7 @@ public function exec(string $statement) : int
/**
* {@inheritdoc}
*/
public function lastInsertId($name = null)
public function lastInsertId(string $name = null) : string
{
return db2_last_insert_id($this->conn);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function query(string $sql) : ResultStatement
/**
* {@inheritdoc}
*/
public function quote($input, $type = ParameterType::STRING)
public function quote($input, $type = ParameterType::STRING) : string
{
return "'" . $this->conn->escape_string($input) . "'";
}
Expand All @@ -166,7 +166,7 @@ public function exec(string $statement) : int
/**
* {@inheritdoc}
*/
public function lastInsertId($name = null)
public function lastInsertId(string $name = null) : string
{
return $this->conn->insert_id;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function query(string $sql) : ResultStatement
/**
* {@inheritdoc}
*/
public function quote($value, $type = ParameterType::STRING)
public function quote($value, $type = ParameterType::STRING) : string
{
if (is_int($value) || is_float($value)) {
return $value;
Expand All @@ -139,7 +139,7 @@ public function exec(string $statement) : int
/**
* {@inheritdoc}
*/
public function lastInsertId($name = null)
public function lastInsertId(string $name = null) : string
{
if ($name === null) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ public function query(string $sql) : ResultStatement
/**
* {@inheritdoc}
*/
public function quote($input, $type = ParameterType::STRING)
public function quote($input, $type = ParameterType::STRING) : string
{
return $this->connection->quote($input, $type);
}

/**
* {@inheritdoc}
*/
public function lastInsertId($name = null)
public function lastInsertId(string $name = null) : string
{
return $this->connection->lastInsertId($name);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Connection extends PDOConnection implements \Doctrine\DBAL\Driver\Connecti
/**
* {@inheritDoc}
*/
public function lastInsertId($name = null)
public function lastInsertId(string $name = null) : string
{
if ($name === null) {
return parent::lastInsertId($name);
Expand All @@ -31,7 +31,7 @@ public function lastInsertId($name = null)
/**
* {@inheritDoc}
*/
public function quote($value, $type = ParameterType::STRING)
public function quote($value, $type = ParameterType::STRING) : string
{
$val = parent::quote($value, $type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function getServerVersion()
/**
* {@inheritdoc}
*/
public function lastInsertId($name = null)
public function lastInsertId(string $name = null) : string
{
if ($name === null) {
return sasql_insert_id($this->connection);
Expand Down Expand Up @@ -164,7 +164,7 @@ public function query(string $sql) : ResultStatement
/**
* {@inheritdoc}
*/
public function quote($input, $type = ParameterType::STRING)
public function quote($input, $type = ParameterType::STRING) : string
{
if (is_int($input) || is_float($input)) {
return $input;
Expand Down
4 changes: 2 additions & 2 deletions lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function query(string $sql) : ResultStatement
/**
* {@inheritDoc}
*/
public function quote($value, $type = ParameterType::STRING)
public function quote($value, $type = ParameterType::STRING) : string
{
if (is_int($value)) {
return $value;
Expand Down Expand Up @@ -120,7 +120,7 @@ public function exec(string $statement) : int
/**
* {@inheritDoc}
*/
public function lastInsertId($name = null)
public function lastInsertId(string $name = null) : string
{
if ($name !== null) {
$stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?');
Expand Down

0 comments on commit 5da6be5

Please sign in to comment.