Skip to content

Commit 0f36981

Browse files
committed
Update PDO parameter names
Followup to previous changes: * Use camel case, as PDO uses a camel case OO API. * Use &$var instead of &$bind_var or &$param. * Use $column instead of $index. We have cases (both inside PDO and in other DB exts) where columns can also be represented as strings, so $column is the safer generic name. Closes GH-6272.
1 parent dba6715 commit 0f36981

7 files changed

+31
-31
lines changed

ext/pdo/pdo_dbh.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public function inTransaction() {}
3434
public function lastInsertId(?string $name = null) {}
3535

3636
/** @return PDOStatement|false */
37-
public function prepare(string $query, array $driver_options = []) {}
37+
public function prepare(string $query, array $options = []) {}
3838

3939
/** @return PDOStatement|false */
40-
public function query(string $query, ?int $fetch_mode = null, mixed ...$fetch_mode_args) {}
40+
public function query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs) {}
4141

4242
/** @return string|false */
4343
public function quote(string $string, int $type = PDO::PARAM_STR) {}

ext/pdo/pdo_dbh_arginfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 2bee02a9952faf3f768873bafe1be9ef89086029 */
2+
* Stub hash: 788d1cd616c140df4072c6e0564c2995fbdc84ad */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, dsn, IS_STRING, 0)
@@ -35,13 +35,13 @@ ZEND_END_ARG_INFO()
3535

3636
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_prepare, 0, 0, 1)
3737
ZEND_ARG_TYPE_INFO(0, query, IS_STRING, 0)
38-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, driver_options, IS_ARRAY, 0, "[]")
38+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
3939
ZEND_END_ARG_INFO()
4040

4141
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_query, 0, 0, 1)
4242
ZEND_ARG_TYPE_INFO(0, query, IS_STRING, 0)
43-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fetch_mode, IS_LONG, 1, "null")
44-
ZEND_ARG_VARIADIC_TYPE_INFO(0, fetch_mode_args, IS_MIXED, 0)
43+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fetchMode, IS_LONG, 1, "null")
44+
ZEND_ARG_VARIADIC_TYPE_INFO(0, fetchModeArgs, IS_MIXED, 0)
4545
ZEND_END_ARG_INFO()
4646

4747
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_quote, 0, 0, 1)

ext/pdo/pdo_stmt.stub.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
class PDOStatement implements IteratorAggregate
66
{
77
/** @return bool */
8-
public function bindColumn(string|int $column, mixed &$param, int $type = 0, int $max_length = 0, mixed $driver_options = null) {}
8+
public function bindColumn(string|int $column, mixed &$var, int $type = 0, int $maxLength = 0, mixed $driverOptions = null) {}
99

1010
/** @return bool */
11-
public function bindParam(string|int $param, mixed &$bind_var, int $type = PDO::PARAM_STR, int $max_length = 0, mixed $driver_options = null) {}
11+
public function bindParam(string|int $param, mixed &$var, int $type = PDO::PARAM_STR, int $maxLength = 0, mixed $driverOptions = null) {}
1212

1313
/** @return bool */
1414
public function bindValue(string|int $param, mixed $value, int $type = PDO::PARAM_STR) {}
@@ -29,25 +29,25 @@ public function errorCode() {}
2929
public function errorInfo() {}
3030

3131
/** @return bool */
32-
public function execute(?array $input_parameters = null) {}
32+
public function execute(?array $params = null) {}
3333

3434
/** @return mixed */
35-
public function fetch(int $mode = PDO::FETCH_BOTH, int $cursor_orientation = PDO::FETCH_ORI_NEXT, int $cursor_offset = 0) {}
35+
public function fetch(int $mode = PDO::FETCH_BOTH, int $cursorOrientation = PDO::FETCH_ORI_NEXT, int $cursorOffset = 0) {}
3636

3737
/** @return array */
3838
public function fetchAll(int $mode = PDO::FETCH_BOTH, mixed ...$args) {}
3939

4040
/** @return mixed */
41-
public function fetchColumn(int $index = 0) {}
41+
public function fetchColumn(int $column = 0) {}
4242

4343
/** @return mixed */
44-
public function fetchObject(?string $class = "stdClass", ?array $constructor_args = null) {}
44+
public function fetchObject(?string $class = "stdClass", ?array $ctorArgs = null) {}
4545

4646
/** @return mixed */
4747
public function getAttribute(int $name) {}
4848

4949
/** @return array|false */
50-
public function getColumnMeta(int $index) {}
50+
public function getColumnMeta(int $column) {}
5151

5252
/** @return bool */
5353
public function nextRowset() {}
@@ -59,7 +59,7 @@ public function rowCount() {}
5959
public function setAttribute(int $attribute, mixed $value) {}
6060

6161
/** @return bool */
62-
public function setFetchMode(int $mode, mixed ...$fetch_mode_args) {}
62+
public function setFetchMode(int $mode, mixed ...$args) {}
6363

6464
public function getIterator(): Iterator {}
6565
}

ext/pdo/pdo_stmt_arginfo.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: b3338fc077eab1280da093f059fac14dd7f19678 */
2+
* Stub hash: 574055f1dbb6a1bee10e4476642a759e53ca2802 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindColumn, 0, 0, 2)
55
ZEND_ARG_TYPE_MASK(0, column, MAY_BE_STRING|MAY_BE_LONG, NULL)
6-
ZEND_ARG_TYPE_INFO(1, param, IS_MIXED, 0)
6+
ZEND_ARG_TYPE_INFO(1, var, IS_MIXED, 0)
77
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "0")
8-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_length, IS_LONG, 0, "0")
9-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, driver_options, IS_MIXED, 0, "null")
8+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxLength, IS_LONG, 0, "0")
9+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, driverOptions, IS_MIXED, 0, "null")
1010
ZEND_END_ARG_INFO()
1111

1212
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindParam, 0, 0, 2)
1313
ZEND_ARG_TYPE_MASK(0, param, MAY_BE_STRING|MAY_BE_LONG, NULL)
14-
ZEND_ARG_TYPE_INFO(1, bind_var, IS_MIXED, 0)
14+
ZEND_ARG_TYPE_INFO(1, var, IS_MIXED, 0)
1515
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "PDO::PARAM_STR")
16-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_length, IS_LONG, 0, "0")
17-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, driver_options, IS_MIXED, 0, "null")
16+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxLength, IS_LONG, 0, "0")
17+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, driverOptions, IS_MIXED, 0, "null")
1818
ZEND_END_ARG_INFO()
1919

2020
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindValue, 0, 0, 2)
@@ -35,13 +35,13 @@ ZEND_END_ARG_INFO()
3535
#define arginfo_class_PDOStatement_errorInfo arginfo_class_PDOStatement_closeCursor
3636

3737
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_execute, 0, 0, 0)
38-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, input_parameters, IS_ARRAY, 1, "null")
38+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, params, IS_ARRAY, 1, "null")
3939
ZEND_END_ARG_INFO()
4040

4141
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetch, 0, 0, 0)
4242
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "PDO::FETCH_BOTH")
43-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cursor_orientation, IS_LONG, 0, "PDO::FETCH_ORI_NEXT")
44-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cursor_offset, IS_LONG, 0, "0")
43+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cursorOrientation, IS_LONG, 0, "PDO::FETCH_ORI_NEXT")
44+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cursorOffset, IS_LONG, 0, "0")
4545
ZEND_END_ARG_INFO()
4646

4747
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchAll, 0, 0, 0)
@@ -50,20 +50,20 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchAll, 0, 0, 0)
5050
ZEND_END_ARG_INFO()
5151

5252
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchColumn, 0, 0, 0)
53-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, index, IS_LONG, 0, "0")
53+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, column, IS_LONG, 0, "0")
5454
ZEND_END_ARG_INFO()
5555

5656
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchObject, 0, 0, 0)
5757
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, class, IS_STRING, 1, "\"stdClass\"")
58-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, constructor_args, IS_ARRAY, 1, "null")
58+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, ctorArgs, IS_ARRAY, 1, "null")
5959
ZEND_END_ARG_INFO()
6060

6161
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_getAttribute, 0, 0, 1)
6262
ZEND_ARG_TYPE_INFO(0, name, IS_LONG, 0)
6363
ZEND_END_ARG_INFO()
6464

6565
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_getColumnMeta, 0, 0, 1)
66-
ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0)
66+
ZEND_ARG_TYPE_INFO(0, column, IS_LONG, 0)
6767
ZEND_END_ARG_INFO()
6868

6969
#define arginfo_class_PDOStatement_nextRowset arginfo_class_PDOStatement_closeCursor
@@ -77,7 +77,7 @@ ZEND_END_ARG_INFO()
7777

7878
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_setFetchMode, 0, 0, 1)
7979
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
80-
ZEND_ARG_VARIADIC_TYPE_INFO(0, fetch_mode_args, IS_MIXED, 0)
80+
ZEND_ARG_VARIADIC_TYPE_INFO(0, args, IS_MIXED, 0)
8181
ZEND_END_ARG_INFO()
8282

8383
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_PDOStatement_getIterator, 0, 0, Iterator, 0)

ext/pdo/tests/bug_44173.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ try {
7373
?>
7474
--EXPECT--
7575
PDO::query() expects exactly 2 arguments for the fetch mode provided, 4 given
76-
PDO::query(): Argument #2 ($fetch_mode) must be of type ?int, string given
76+
PDO::query(): Argument #2 ($fetchMode) must be of type ?int, string given
7777
PDO::query() expects at most 4 arguments for the fetch mode provided, 5 given
7878
PDO::query() expects exactly 3 arguments for the fetch mode provided, 2 given
7979
PDO::query() expects exactly 3 arguments for the fetch mode provided, 2 given

ext/pdo_mysql/tests/bug_37445.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $stmt = $db->prepare("SELECT 1");
1717
$stmt->bindParam(':a', 'b');
1818
?>
1919
--EXPECTF--
20-
Fatal error: Uncaught Error: PDOStatement::bindParam(): Argument #2 ($bind_var) cannot be passed by reference in %sbug_37445.php:%d
20+
Fatal error: Uncaught Error: PDOStatement::bindParam(): Argument #2 ($var) cannot be passed by reference in %sbug_37445.php:%d
2121
Stack trace:
2222
#0 {main}
2323
thrown in %sbug_37445.php on line %d

ext/pdo_mysql/tests/pdo_mysql_stmt_getcolumnmeta.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,6 @@ $db->exec('DROP TABLE IF EXISTS test');
302302
print "done!";
303303
?>
304304
--EXPECT--
305-
PDOStatement::getColumnMeta(): Argument #1 ($index) must be greater than or equal to 0
305+
PDOStatement::getColumnMeta(): Argument #1 ($column) must be greater than or equal to 0
306306
Testing native PS...
307307
done!

0 commit comments

Comments
 (0)