From 972da55d842ebfd422a3842e78d0bdfa9496f3d0 Mon Sep 17 00:00:00 2001 From: Holger Woltersdorf Date: Thu, 31 Dec 2020 01:59:10 +0100 Subject: [PATCH] Add missing param for constructor arguments in PDOStatement#fetchObject (#4915) * Add missing param for constructor arguments PDOStatement#fetchObject allows a second, optional parameter for constructor arguments, which - if given - will be passed to the given class' constructor. See: https://www.php.net/manual/de/pdostatement.fetchobject.php Also see the PhpStorm stubs: https://github.com/JetBrains/phpstorm-stubs/blob/master/PDO/PDO.php#L1441 * Fix wrong nullability for 2nd argument in PDOStatement#fetchObject --- dictionaries/CallMap.php | 2 +- stubs/pdo.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index ed8af0052..864e3245d 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -9884,7 +9884,7 @@ return [ 'PDOStatement::fetch' => ['mixed', 'how='=>'int', 'orientation='=>'int', 'offset='=>'int'], 'PDOStatement::fetchAll' => ['array|false', 'how='=>'int', 'fetch_argument='=>'int|string|callable', 'ctor_args='=>'?array'], 'PDOStatement::fetchColumn' => ['string|int|float|bool|null', 'column_number='=>'int'], -'PDOStatement::fetchObject' => ['object|false', 'class_name='=>'string', 'ctor_args='=>'?array'], +'PDOStatement::fetchObject' => ['object|false', 'class_name='=>'string', 'ctor_args='=>'array'], 'PDOStatement::getAttribute' => ['mixed', 'attribute'=>'int'], 'PDOStatement::getColumnMeta' => ['array|false', 'column'=>'int'], 'PDOStatement::nextRowset' => ['bool'], diff --git a/stubs/pdo.php b/stubs/pdo.php index cc034788f..695b1f438 100644 --- a/stubs/pdo.php +++ b/stubs/pdo.php @@ -6,7 +6,8 @@ class PdoStatement { * * @template T * @param class-string $class + * @param array $ctorArgs * @return false|T */ - public function fetchObject($class = "stdclass") {} + public function fetchObject($class = "stdclass", array $ctorArgs = array()) {} }