Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Dec 12, 2022

These types are part of phpstan-dba for a couple of releases, and therefore can be considered kind of battle tested

@staabm staabm marked this pull request as ready for review December 12, 2022 19:59
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@@ -7,5 +7,16 @@
*/
class PDOStatement implements Traversable, IteratorAggregate
{
/**
* @template T
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks fixed

* @param array<mixed> $ctorArgs
* @return false|T
*/
public function fetchObject($class = \stdclass::class, array $ctorArgs = array()) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's stdClass

@ondrejmirtes ondrejmirtes merged commit 1cf9968 into phpstan:1.9.x Dec 13, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the pdostub branch December 13, 2022 08:36
@@ -7,5 +7,16 @@
*/
class PDOStatement implements Traversable, IteratorAggregate
Copy link
Contributor Author

@staabm staabm Dec 13, 2022

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.

Copy link
Member

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 :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants