Skip to content

Commit 35ac9c7

Browse files
committed
Declared Driver\Statement::bind(Parameter|Value) $name argument as string|ing
1 parent 09f69fb commit 35ac9c7

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

src/Driver/IBMDB2/DB2Statement.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use const DB2_PARAM_FILE;
1919
use const DB2_PARAM_IN;
2020
use function array_change_key_case;
21+
use function assert;
2122
use function count;
2223
use function db2_bind_param;
2324
use function db2_execute;
@@ -34,6 +35,7 @@
3435
use function fclose;
3536
use function fwrite;
3637
use function gettype;
38+
use function is_int;
3739
use function is_object;
3840
use function is_resource;
3941
use function is_string;
@@ -97,6 +99,8 @@ public function bindValue($param, $value, $type = ParameterType::STRING)
9799
*/
98100
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
99101
{
102+
assert(is_int($column));
103+
100104
switch ($type) {
101105
case ParameterType::INTEGER:
102106
$this->bind($column, $variable, DB2_PARAM_IN, DB2_LONG);

src/Driver/SQLAnywhere/SQLAnywhereStatement.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use stdClass;
1313
use const SASQL_BOTH;
1414
use function array_key_exists;
15+
use function assert;
1516
use function count;
1617
use function gettype;
1718
use function is_int;
@@ -88,6 +89,8 @@ public function __construct($conn, $sql)
8889
*/
8990
public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
9091
{
92+
assert(is_int($column));
93+
9194
switch ($type) {
9295
case ParameterType::INTEGER:
9396
case ParameterType::BOOLEAN:

src/Driver/Statement.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ interface Statement extends ResultStatement
1919
* As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
2020
* fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
2121
*
22-
* @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
23-
* this will be a parameter name of the form :name. For a prepared statement
24-
* using question mark placeholders, this will be the 1-indexed position of the parameter.
25-
* @param mixed $value The value to bind to the parameter.
26-
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
27-
* constants.
22+
* @param string|int $param Parameter identifier. For a prepared statement using named placeholders,
23+
* this will be a parameter name of the form :name. For a prepared statement
24+
* using question mark placeholders, this will be the 1-indexed position of the parameter.
25+
* @param mixed $value The value to bind to the parameter.
26+
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
27+
* constants.
2828
*
2929
* @return bool TRUE on success or FALSE on failure.
3030
*/
@@ -44,14 +44,14 @@ public function bindValue($param, $value, $type = ParameterType::STRING);
4444
* of stored procedures that return data as output parameters, and some also as input/output
4545
* parameters that both send in data and are updated to receive it.
4646
*
47-
* @param mixed $column Parameter identifier. For a prepared statement using named placeholders,
48-
* this will be a parameter name of the form :name. For a prepared statement using
49-
* question mark placeholders, this will be the 1-indexed position of the parameter.
50-
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
51-
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
52-
* constants.
53-
* @param int|null $length You must specify maxlength when using an OUT bind
54-
* so that PHP allocates enough memory to hold the returned value.
47+
* @param string|int $column Parameter identifier. For a prepared statement using named placeholders,
48+
* this will be a parameter name of the form :name. For a prepared statement using
49+
* question mark placeholders, this will be the 1-indexed position of the parameter.
50+
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
51+
* @param int $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
52+
* constants.
53+
* @param int|null $length You must specify maxlength when using an OUT bind
54+
* so that PHP allocates enough memory to hold the returned value.
5555
*
5656
* @return bool TRUE on success or FALSE on failure.
5757
*/

0 commit comments

Comments
 (0)