-
Notifications
You must be signed in to change notification settings - Fork 529
Declare more PDOStatement method types #2096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This pull request has been marked as ready for review. |
stubs/PDOStatement.stub
Outdated
@@ -7,5 +7,16 @@ | |||
*/ | |||
class PDOStatement implements Traversable, IteratorAggregate | |||
{ | |||
/** | |||
* @template T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be T of object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks fixed
stubs/PDOStatement.stub
Outdated
* @param array<mixed> $ctorArgs | ||
* @return false|T | ||
*/ | ||
public function fetchObject($class = \stdclass::class, array $ctorArgs = array()) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's stdClass
Thank you! |
@@ -7,5 +7,16 @@ | |||
*/ | |||
class PDOStatement implements Traversable, IteratorAggregate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you agree adding a class-level generic for PDOStatement?
/**
* @template rowType
*
* @implements Traversable<int|string, rowType>
* @implements IteratorAggregate<int|string, rowType>
*
* @link https://php.net/manual/en/class.pdostatement.php
*/
I need the class to be generic for phpstan-dba to enrich this type with real-time db schema information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea how this class is used in practice in real-world code so I can't decide this :/
These types are part of phpstan-dba for a couple of releases, and therefore can be considered kind of battle tested