Skip to content

Commit

Permalink
Merge branch '3.4.x' into 4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
morozov committed Aug 4, 2022
2 parents 60f014a + eb78575 commit 7483ccf
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 0 deletions.
9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,15 @@ The following methods have been removed.

# Upgrade to 3.4

## Deprecated wrapper- and driver-level `Statement::bindParam()` methods.

The following methods have been deprecated:

1. `Doctrine\DBAL\Statement::bindParam()`,
2. `Doctrine\DBAL\Driver\Statement::bindParam()`.

Use the corresponding `bindValue()` instead.

## Deprecated not passing parameter type to the driver-level `Statement::bind*()` methods.

Not passing `$type` to the driver-level `Statement::bindParam()` and `::bindValue()` is deprecated.
Expand Down
10 changes: 10 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
See https://github.com/doctrine/dbal/pull/4317
-->
<file name="tests/Functional/LegacyAPITest.php"/>
<!--
TODO: remove in 4.0.0
-->
<referencedMethod name="Doctrine\DBAL\Driver\Statement::bindParam"/>
<referencedMethod name="Doctrine\DBAL\Driver\IBMDB2\Statement::bindParam"/>
<referencedMethod name="Doctrine\DBAL\Driver\Middleware\AbstractStatementMiddleware::bindParam"/>
<referencedMethod name="Doctrine\DBAL\Driver\OCI8\Statement::bindParam"/>
<referencedMethod name="Doctrine\DBAL\Driver\PDO\Statement::bindParam"/>
<referencedMethod name="Doctrine\DBAL\Driver\PDO\SQLSrv\Statement::bindParam"/>
<referencedMethod name="Doctrine\DBAL\Statement::bindParam"/>
</errorLevel>
</DeprecatedMethod>
<DocblockTypeContradiction>
Expand Down
11 changes: 11 additions & 0 deletions src/Driver/IBMDB2/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;

use function assert;
use function db2_bind_param;
Expand Down Expand Up @@ -57,8 +58,18 @@ public function bindValue(int|string $param, mixed $value, ParameterType $type):
$this->bindParam($param, $value, $type);
}

/**
* @deprecated Use {@see bindValue()} instead.
*/
public function bindParam(int|string $param, mixed &$variable, ParameterType $type, ?int $length = null): void
{
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

assert(is_int($param));

switch ($type) {
Expand Down
11 changes: 11 additions & 0 deletions src/Driver/Middleware/AbstractStatementMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\Driver\Result;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;

abstract class AbstractStatementMiddleware implements Statement
{
Expand All @@ -19,12 +20,22 @@ public function bindValue(int|string $param, mixed $value, ParameterType $type):
$this->wrappedStatement->bindValue($param, $value, $type);
}

/**
* @deprecated Use {@see bindValue()} instead.
*/
public function bindParam(
int|string $param,
mixed &$variable,
ParameterType $type,
?int $length = null
): void {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

$this->wrappedStatement->bindParam($param, $variable, $type, $length);
}

Expand Down
11 changes: 11 additions & 0 deletions src/Driver/Mysqli/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;
use mysqli_sql_exception;
use mysqli_stmt;

Expand Down Expand Up @@ -51,12 +52,22 @@ public function __construct(private readonly mysqli_stmt $stmt)
$this->boundValues = array_fill(1, $paramCount, null);
}

/**
* @deprecated Use {@see bindValue()} instead.
*/
public function bindParam(
int|string $param,
mixed &$variable,
ParameterType $type,
?int $length = null
): void {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

assert(is_int($param));

$this->types[$param - 1] = $this->convertParameterType($type);
Expand Down
11 changes: 11 additions & 0 deletions src/Driver/OCI8/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Driver\OCI8\Exception\UnknownParameterIndex;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;

use function is_int;
use function oci_bind_by_name;
Expand Down Expand Up @@ -44,12 +45,22 @@ public function bindValue(int|string $param, mixed $value, ParameterType $type):
$this->bindParam($param, $value, $type);
}

/**
* @deprecated Use {@see bindValue()} instead.
*/
public function bindParam(
int|string $param,
mixed &$variable,
ParameterType $type,
?int $length = null
): void {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

if (is_int($param)) {
if (! isset($this->parameterMap[$param])) {
throw UnknownParameterIndex::new($param);
Expand Down
11 changes: 11 additions & 0 deletions src/Driver/PDO/SQLSrv/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\Driver\Middleware\AbstractStatementMiddleware;
use Doctrine\DBAL\Driver\PDO\Statement as PDOStatement;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;
use PDO;

final class Statement extends AbstractStatementMiddleware
Expand All @@ -23,12 +24,22 @@ public function __construct(PDOStatement $statement)
$this->statement = $statement;
}

/**
* @deprecated Use {@see bindValue()} instead.
*/
public function bindParam(
int|string $param,
mixed &$variable,
ParameterType $type,
?int $length = null
): void {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

switch ($type) {
case ParameterType::LARGE_OBJECT:
case ParameterType::BINARY:
Expand Down
11 changes: 11 additions & 0 deletions src/Driver/PDO/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\Driver\Exception as ExceptionInterface;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;
use PDO;
use PDOException;
use PDOStatement;
Expand All @@ -31,12 +32,22 @@ public function bindValue(int|string $param, mixed $value, ParameterType $type):
}
}

/**
* @deprecated Use {@see bindValue()} instead.
*/
public function bindParam(
string|int $param,
mixed &$variable,
ParameterType $type,
?int $length = null
): void {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

try {
if ($length === null) {
$this->stmt->bindParam($param, $variable, $this->convertParamType($type));
Expand Down
11 changes: 11 additions & 0 deletions src/Driver/SQLSrv/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Driver\SQLSrv\Exception\Error;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;

use function assert;
use function is_int;
Expand Down Expand Up @@ -74,12 +75,22 @@ public function bindValue(int|string $param, mixed $value, ParameterType $type):
$this->types[$param] = $type;
}

/**
* @deprecated Use {@see bindValue()} instead.
*/
public function bindParam(
int|string $param,
mixed &$variable,
ParameterType $type,
?int $length = null
): void {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

assert(is_int($param));

$this->variables[$param] =& $variable;
Expand Down
2 changes: 2 additions & 0 deletions src/Driver/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function bindValue(int|string $param, mixed $value, ParameterType $type):
* 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.
*
* @deprecated Use {@see bindValue()} instead.
*
* @param int|string $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.
Expand Down
11 changes: 11 additions & 0 deletions src/Logging/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\DBAL\Driver\Result as ResultInterface;
use Doctrine\DBAL\Driver\Statement as StatementInterface;
use Doctrine\DBAL\ParameterType;
use Doctrine\Deprecations\Deprecation;
use Psr\Log\LoggerInterface;

final class Statement extends AbstractStatementMiddleware
Expand All @@ -29,12 +30,22 @@ public function __construct(
parent::__construct($statement);
}

/**
* @deprecated Use {@see bindValue()} instead.
*/
public function bindParam(
int|string $param,
mixed &$variable,
ParameterType $type,
?int $length = null
): void {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

$this->params[$param] = &$variable;
$this->types[$param] = $type;

Expand Down
10 changes: 10 additions & 0 deletions src/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
use Doctrine\Deprecations\Deprecation;

use function func_num_args;
use function is_string;
Expand Down Expand Up @@ -102,6 +103,8 @@ public function bindValue(
*
* Binding a parameter by reference does not support DBAL mapping types.
*
* @deprecated Use {@see bindValue()} instead.
*
* @param string|int $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
Expand All @@ -119,6 +122,13 @@ public function bindParam(
ParameterType $type = ParameterType::STRING,
?int $length = null
): void {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

$this->params[$param] = $variable;
$this->types[$param] = $type;

Expand Down

0 comments on commit 7483ccf

Please sign in to comment.