Skip to content

Conversation

@staabm
Copy link
Owner

@staabm staabm commented Mar 5, 2025

closes #748

$stmt = $pdo->query('SELECT email, adaid FROM ada', PDO::FETCH_OBJ);
foreach ($stmt as $row) {
assertType('array<int, stdClass>', $row);
assertType('object{email: string, adaid: int<-32768, 32767>}&stdClass', $row);
Copy link
Owner Author

@staabm staabm Mar 5, 2025

Choose a reason for hiding this comment

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

@AllenJB does this look better/correct for you?

Copy link

Choose a reason for hiding this comment

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

Looks good to me. Thanks! 👍

Copy link
Owner Author

Choose a reason for hiding this comment

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

@AllenJB could you please fill another issue with your feature request regarding "how can I put a type onto a result-object" and your concrete use-case/example?

Copy link

Choose a reason for hiding this comment

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

I assume you're referring to phpstan/phpstan#9120

Did you just want me to repost that as a request on the phpstan-dba project? Or is there some information that's missing from there?

Did you see my latest comment with the reproducer repo I set up (which I've just updated for these changes)? And the related request for help I linked to on the phpstan project discussions? (Not sure how much the last will help you - it's just my current line of thinking on how to implement something that solves fetch mode handling well-enough to get back to at least what I had with the PDOStatement stub override under PHPStan 1)

Copy link
Owner Author

Choose a reason for hiding this comment

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

I see, lets discuss in the already open discussion

@staabm staabm merged commit 813afaa into main Mar 5, 2025
26 checks passed
@staabm staabm deleted the pdo-obj branch March 5, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants