Skip to content

Commit cfaa270

Browse files
committed
Use variadic signature for PDOStatement::fetchAll()
The current signature is incorrect, because the $ctor_args parameter is not required to be an array (it can at least also be null, and isn't enforced by an exception anyway). I'm going for the variadic signature here, because we already use the same variadic signature in PDO::query() and PDOStatement::setFetchMode(), all of them accepting essentially the same arguments.
1 parent ca20f36 commit cfaa270

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

ext/pdo/pdo_stmt.stub.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@ public function execute(?array $input_parameters = null) {}
3434
/** @return mixed */
3535
public function fetch(int $fetch_style = PDO::FETCH_BOTH, int $cursor_orientation = PDO::FETCH_ORI_NEXT, int $cursor_offset = 0) {}
3636

37-
/**
38-
* @param mixed $fetch_argument
39-
* @return array|false
40-
*/
41-
public function fetchAll(int $fetch_style = PDO::FETCH_BOTH, $fetch_argument = UNKNOWN, array $ctor_args = []) {}
37+
/** @return array|false */
38+
public function fetchAll(int $fetch_style = PDO::FETCH_BOTH, mixed ...$fetch_args) {}
4239

4340
/** @return mixed */
4441
public function fetchColumn(int $column_number = 0) {}

ext/pdo/pdo_stmt_arginfo.h

Lines changed: 2 additions & 3 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: d64c75660cfc44b582e7dcc20c4ce22e8e0848e1 */
2+
* Stub hash: 45c43e025d9194f2dd7b2ab13d86a4e5f316fa48 */
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)
@@ -46,8 +46,7 @@ ZEND_END_ARG_INFO()
4646

4747
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchAll, 0, 0, 0)
4848
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fetch_style, IS_LONG, 0, "PDO::FETCH_BOTH")
49-
ZEND_ARG_INFO(0, fetch_argument)
50-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, ctor_args, IS_ARRAY, 0, "[]")
49+
ZEND_ARG_VARIADIC_TYPE_INFO(0, fetch_args, IS_MIXED, 0)
5150
ZEND_END_ARG_INFO()
5251

5352
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_fetchColumn, 0, 0, 0)

ext/pdo_mysql/tests/pdo_mysql_attr_statement_class.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ $db = MySQLPDOTest::factory();
7979
$stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2');
8080

8181
class mystatement5 extends mystatement4 {
82-
public function fetchAll($fetch_style = 1, $column_index = 1, $ctor_args = array()) {
82+
public function fetchAll($fetch_style = 1, ...$fetch_args) {
8383
return "no data :)";
8484
}
8585
}

0 commit comments

Comments
 (0)