Skip to content

Commit

Permalink
Fix argument type declaration
Browse files Browse the repository at this point in the history
By either defining their types or renaming to match parent class (or
interface).
  • Loading branch information
lcobucci committed Jan 2, 2020
1 parent 52f47b1 commit fd89091
Show file tree
Hide file tree
Showing 28 changed files with 198 additions and 575 deletions.
16 changes: 9 additions & 7 deletions lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public function isConnectedToMaster()
}

/**
* {@inheritDoc}
* @param string|null $connectionName
*
* @return bool
*/
public function connect($connectionName = null)
{
Expand Down Expand Up @@ -259,11 +261,11 @@ public function rollBack()
/**
* {@inheritDoc}
*/
public function delete($tableName, array $identifier, array $types = [])
public function delete($tableExpression, array $identifier, array $types = [])
{
$this->connect('master');

return parent::delete($tableName, $identifier, $types);
return parent::delete($tableExpression, $identifier, $types);
}

/**
Expand All @@ -282,21 +284,21 @@ public function close()
/**
* {@inheritDoc}
*/
public function update($tableName, array $data, array $identifier, array $types = [])
public function update($tableExpression, array $data, array $identifier, array $types = [])
{
$this->connect('master');

return parent::update($tableName, $data, $identifier, $types);
return parent::update($tableExpression, $data, $identifier, $types);
}

/**
* {@inheritDoc}
*/
public function insert($tableName, array $data, array $types = [])
public function insert($tableExpression, array $data, array $types = [])
{
$this->connect('master');

return parent::insert($tableName, $data, $types);
return parent::insert($tableExpression, $data, $types);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/DBALException.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static function driverException(Driver $driver, Throwable $driverEx)
/**
* @return self
*/
private static function wrapException(Driver $driver, Throwable $driverEx, $msg)
private static function wrapException(Driver $driver, Throwable $driverEx, string $msg)
{
if ($driverEx instanceof DriverException) {
return $driverEx;
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class Connection extends PDOConnection
/**
* {@inheritdoc}
*/
public function quote($value, $type = ParameterType::STRING)
public function quote($input, $type = ParameterType::STRING)
{
if ($type === ParameterType::BOOLEAN) {
return $value ? 'true' : 'false';
return $input ? 'true' : 'false';
}

return parent::quote($value, $type);
return parent::quote($input, $type);
}
}
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 @@ -76,9 +76,9 @@ public function requiresQueryForServerVersion()
/**
* {@inheritdoc}
*/
public function prepare($sql)
public function prepare($prepareString)
{
$stmt = @db2_prepare($this->conn, $sql);
$stmt = @db2_prepare($this->conn, $prepareString);
if (! $stmt) {
throw new DB2Exception(db2_stmt_errormsg());
}
Expand Down
6 changes: 5 additions & 1 deletion lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ private function bindTypedParameters() : void
$types = $this->types;

foreach ($this->_bindedValues as $parameter => $value) {
assert(is_int($parameter));

if (! isset($types[$parameter - 1])) {
$types[$parameter - 1] = static::$_paramTypeMap[ParameterType::STRING];
}
Expand Down Expand Up @@ -243,9 +245,11 @@ private function bindTypedParameters() : void
/**
* Handle $this->_longData after regular query parameters have been bound
*
* @param array<int, resource> $streams
*
* @throws MysqliException
*/
private function sendLongData($streams) : void
private function sendLongData(array $streams) : void
{
foreach ($streams as $paramNr => $stream) {
while (! feof($stream)) {
Expand Down
10 changes: 5 additions & 5 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ public function query()
/**
* {@inheritdoc}
*/
public function quote($value, $type = ParameterType::STRING)
public function quote($input, $type = ParameterType::STRING)
{
if (is_int($value) || is_float($value)) {
return $value;
if (is_int($input) || is_float($input)) {
return $input;
}
$value = str_replace("'", "''", $value);
$input = str_replace("'", "''", $input);

return "'" . addcslashes($value, "\000\n\r\\\032") . "'";
return "'" . addcslashes($input, "\000\n\r\\\032") . "'";
}

/**
Expand Down
14 changes: 7 additions & 7 deletions lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
/**
* {@inheritdoc}
*/
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null)
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
{
if (is_int($param)) {
if (! isset($this->_paramMap[$param])) {
throw new OCI8Exception(sprintf('Could not find variable mapping with index %d, in the SQL statement', $param));
if (is_int($column)) {
if (! isset($this->_paramMap[$column])) {
throw new OCI8Exception(sprintf('Could not find variable mapping with index %d, in the SQL statement', $column));
}

$param = $this->_paramMap[$param];
$column = $this->_paramMap[$column];
}

if ($type === ParameterType::LARGE_OBJECT) {
Expand All @@ -297,11 +297,11 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le
$variable =& $lob;
}

$this->boundValues[$param] =& $variable;
$this->boundValues[$column] =& $variable;

return oci_bind_by_name(
$this->_sth,
$param,
$column,
$variable,
$length ?? -1,
$this->convertParameterType($type)
Expand Down
5 changes: 4 additions & 1 deletion lib/Doctrine/DBAL/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public function getServerVersion()
}

/**
* {@inheritdoc}
* @param string $prepareString
* @param array<int, int> $driverOptions
*
* @return Statement
*/
public function prepare($prepareString, $driverOptions = [])
{
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 @@ -40,9 +40,9 @@ public function lastInsertId($name = null)
/**
* {@inheritDoc}
*/
public function quote($value, $type = ParameterType::STRING)
public function quote($input, $type = ParameterType::STRING)
{
$val = parent::quote($value, $type);
$val = parent::quote($input, $type);

// Fix for a driver version terminating all values with null byte
if (strpos($val, "\0") !== false) {
Expand Down
8 changes: 7 additions & 1 deletion lib/Doctrine/DBAL/Driver/PDOStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
}

/**
* {@inheritdoc}
* @param mixed $column
* @param mixed $variable
* @param int $type
* @param int|null $length
* @param mixed $driverOptions
*
* @return bool
*/
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null)
{
Expand Down
16 changes: 8 additions & 8 deletions lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public function requiresQueryForServerVersion()
/**
* {@inheritDoc}
*/
public function prepare($sql)
public function prepare($prepareString)
{
return new SQLSrvStatement($this->conn, $sql, $this->lastInsertId);
return new SQLSrvStatement($this->conn, $prepareString, $this->lastInsertId);
}

/**
Expand All @@ -96,17 +96,17 @@ public function query()
/**
* {@inheritDoc}
*/
public function quote($value, $type = ParameterType::STRING)
public function quote($input, $type = ParameterType::STRING)
{
if (is_int($value)) {
return $value;
if (is_int($input)) {
return $input;
}

if (is_float($value)) {
return sprintf('%F', $value);
if (is_float($input)) {
return sprintf('%F', $input);
}

return "'" . str_replace("'", "''", $value) . "'";
return "'" . str_replace("'", "''", $input) . "'";
}

/**
Expand Down
34 changes: 19 additions & 15 deletions lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ public function getDateDiffExpression($date1, $date2)
/**
* {@inheritDoc}
*/
public function getBooleanTypeDeclarationSQL(array $field)
public function getBooleanTypeDeclarationSQL(array $columnDef)
{
return 'BOOLEAN';
}

/**
* {@inheritDoc}
*/
public function getIntegerTypeDeclarationSQL(array $field)
public function getIntegerTypeDeclarationSQL(array $columnDef)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
}

/**
Expand All @@ -100,17 +100,17 @@ protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
/**
* {@inheritDoc}
*/
public function getBigIntTypeDeclarationSQL(array $field)
public function getBigIntTypeDeclarationSQL(array $columnDef)
{
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
}

/**
* {@inheritDoc}
*/
public function getSmallIntTypeDeclarationSQL(array $field)
public function getSmallIntTypeDeclarationSQL(array $columnDef)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
return 'INT' . $this->_getCommonIntegerTypeDeclarationSQL($columnDef);
}

/**
Expand Down Expand Up @@ -170,17 +170,17 @@ public function getBlobTypeDeclarationSQL(array $field)
/**
* {@inheritDoc}
*/
public function getCreateDatabaseSQL($name)
public function getCreateDatabaseSQL($database)
{
return 'CREATE DATABASE ' . $name;
return 'CREATE DATABASE ' . $database;
}

/**
* {@inheritDoc}
*/
public function getDropDatabaseSQL($name)
public function getDropDatabaseSQL($database)
{
return 'DROP DATABASE ' . $name;
return 'DROP DATABASE ' . $database;
}

/**
Expand Down Expand Up @@ -335,7 +335,10 @@ public function getListTableColumnsSQL($table, $database = null)
}

/**
* {@inheritDoc}
* @param string $table
* @param string|null $database
*
* @return string
*/
public function getListTableForeignKeysSQL($table, $database = null)
{
Expand All @@ -353,10 +356,10 @@ public function getListTableForeignKeysSQL($table, $database = null)
/**
* {@inheritDoc}
*/
public function getListTableIndexesSQL($table, $database = null)
public function getListTableIndexesSQL($table, $currentDatabase = null)
{
if ($database) {
$databaseSQL = $this->quoteStringLiteral($database);
if ($currentDatabase) {
$databaseSQL = $this->quoteStringLiteral($currentDatabase);
} else {
$databaseSQL = 'DATABASE()';
}
Expand Down Expand Up @@ -435,6 +438,7 @@ public function getDropIndexSQL($index, $table = null)
}

/**
* @param string $table
*
* @return string
*/
Expand Down
Loading

0 comments on commit fd89091

Please sign in to comment.