Skip to content

Commit

Permalink
Merge pull request #5563 from morozov/deprecate-bind-params
Browse files Browse the repository at this point in the history
Deprecate Statement::bindParam()
  • Loading branch information
morozov committed Aug 4, 2022
2 parents bf648df + 66bcb9b commit eb78575
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 0 deletions.
9 changes: 9 additions & 0 deletions UPGRADE.md
Expand Up @@ -8,6 +8,15 @@ awareness about deprecated code.

# 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
Expand Up @@ -399,6 +399,16 @@
-->
<referencedMethod name="Doctrine\DBAL\Query\QueryBuilder::getState"/>
<referencedMethod name="Doctrine\DBAL\Query\QueryBuilder::getType"/>
<!--
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>
<DeprecatedProperty>
Expand Down
9 changes: 9 additions & 0 deletions src/Driver/IBMDB2/Statement.php
Expand Up @@ -76,9 +76,18 @@ public function bindValue($param, $value, $type = ParameterType::STRING): bool

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

assert(is_int($param));

if (func_num_args() < 3) {
Expand Down
9 changes: 9 additions & 0 deletions src/Driver/Middleware/AbstractStatementMiddleware.php
Expand Up @@ -37,9 +37,18 @@ public function bindValue($param, $value, $type = ParameterType::STRING)

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

if (func_num_args() < 3) {
Deprecation::trigger(
'doctrine/dbal',
Expand Down
9 changes: 9 additions & 0 deletions src/Driver/Mysqli/Statement.php
Expand Up @@ -66,9 +66,18 @@ public function __construct(mysqli_stmt $stmt)

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

assert(is_int($param));

if (func_num_args() < 3) {
Expand Down
9 changes: 9 additions & 0 deletions src/Driver/OCI8/Statement.php
Expand Up @@ -70,9 +70,18 @@ public function bindValue($param, $value, $type = ParameterType::STRING): bool

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

if (func_num_args() < 3) {
Deprecation::trigger(
'doctrine/dbal',
Expand Down
9 changes: 9 additions & 0 deletions src/Driver/PDO/SQLSrv/Statement.php
Expand Up @@ -27,6 +27,8 @@ public function __construct(PDOStatement $statement)
/**
* {@inheritdoc}
*
* @deprecated Use {@see bindValue()} instead.
*
* @param string|int $param
* @param mixed $variable
* @param int $type
Expand All @@ -40,6 +42,13 @@ public function bindParam(
$length = null,
$driverOptions = null
): bool {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

if (func_num_args() < 3) {
Deprecation::trigger(
'doctrine/dbal',
Expand Down
9 changes: 9 additions & 0 deletions src/Driver/PDO/Statement.php
Expand Up @@ -64,6 +64,8 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
/**
* {@inheritDoc}
*
* @deprecated Use {@see bindValue()} instead.
*
* @param mixed $param
* @param mixed $variable
* @param int $type
Expand All @@ -77,6 +79,13 @@ public function bindParam(
$length = null,
$driverOptions = null
): bool {
Deprecation::trigger(
'doctrine/dbal',
'https://github.com/doctrine/dbal/pull/5563',
'%s is deprecated. Use bindValue() instead.',
__METHOD__
);

if (func_num_args() < 3) {
Deprecation::trigger(
'doctrine/dbal',
Expand Down
9 changes: 9 additions & 0 deletions src/Driver/SQLSrv/Statement.php
Expand Up @@ -105,9 +105,18 @@ public function bindValue($param, $value, $type = ParameterType::STRING): bool

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

assert(is_int($param));

if (func_num_args() < 3) {
Expand Down
2 changes: 2 additions & 0 deletions src/Driver/Statement.php
Expand Up @@ -43,6 +43,8 @@ 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.
*
* @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 of the parameter.
Expand Down
9 changes: 9 additions & 0 deletions src/Logging/Statement.php
Expand Up @@ -39,9 +39,18 @@ public function __construct(StatementInterface $statement, LoggerInterface $logg

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

if (func_num_args() < 3) {
Deprecation::trigger(
'doctrine/dbal',
Expand Down
9 changes: 9 additions & 0 deletions src/Statement.php
Expand Up @@ -123,6 +123,8 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
*
* Binding a parameter by reference does not support DBAL mapping types.
*
* @deprecated Use {@see bindValue()} instead.
*
* @param string|int $param The name or position of the parameter.
* @param mixed $variable The reference to the variable to bind.
* @param int $type The binding type.
Expand All @@ -135,6 +137,13 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
*/
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null)
{
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 eb78575

Please sign in to comment.