1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-29 20:28:59 +01:00

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
This commit is contained in:
Holger Woltersdorf 2020-12-31 01:59:10 +01:00 committed by Daniil Gentili
parent 491940e4b8
commit 972da55d84
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 3 additions and 2 deletions

View File

@ -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'],

View File

@ -6,7 +6,8 @@ class PdoStatement {
*
* @template T
* @param class-string<T> $class
* @param array $ctorArgs
* @return false|T
*/
public function fetchObject($class = "stdclass") {}
public function fetchObject($class = "stdclass", array $ctorArgs = array()) {}
}