Skip to content

PDOStatement conditional fetch/fetchAll return values#1882

Open
Anders Jenbo (AJenbo) wants to merge 2 commits into
JetBrains:masterfrom
AJenbo:patch-2
Open

PDOStatement conditional fetch/fetchAll return values#1882
Anders Jenbo (AJenbo) wants to merge 2 commits into
JetBrains:masterfrom
AJenbo:patch-2

Conversation

@AJenbo
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread PDO/PDO.php Outdated
* all cases, <b>FALSE</b> is returned on failure.
* @throws PDOException On error if PDO::ERRMODE_EXCEPTION option is true.
*
* @return ($mode is PDO::FETCH_ASSOC ? array<string, mixed>|false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems wrong to have two @return tags inside one PhpDoc. It would be better to use different tag like @psalm-return or @phpstan-return. Or just remove the old @return tag

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I totally missed that, thanks.

I went with the @phpstan-return option since the conditions is already a fairly big block tacking a long comment at the end seems a bit much.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest copying it for psalm (to avoid preferential treatment) and having a simplified @return for e.g. phpstorm.

I also had the same type of failure with those changes and solved it in my PR here: https://github.com/JetBrains/phpstorm-stubs/pull/1810/changes#diff-41a14d60208b4270d5d5d096abca3eb48024718babf786e207c3ab54592000a8R270 (‎tests/StubsPhpDocTest.php)

Copy link
Copy Markdown
Contributor

@staabm Markus Staab (staabm) May 19, 2026

Choose a reason for hiding this comment

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

I suggest copying it for psalm

you should give it a test in psalm before. IIRC psalm (and also PHPStan) pick the others phpdoc (in case no more tools-specific phpdoc exists). so the PR as is, might already work for psalm

Copy link
Copy Markdown
Contributor

@uuf6429 Christian Sciberras (uuf6429) May 19, 2026

Choose a reason for hiding this comment

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

I know they support each other, my concern is more about preferential treatment... Unless the project owners consciously decide to go for one tool and not the other officially, we might end up with different contributions using either tool (inconsistently).

@AJenbo Anders Jenbo (AJenbo) marked this pull request as draft April 30, 2026 11:09
@LolGleb
Copy link
Copy Markdown
Contributor

Hi Anders Jenbo (@AJenbo) , сould you please mark this PR as ready for review? It's currently in draft state, which prevents us from merging it

@uuf6429
Copy link
Copy Markdown
Contributor

Christian Sciberras (uuf6429) commented May 21, 2026

Gleb Sieemshchikov (@LolGleb) there are at least two remaining open points:

  1. Tests are failing because @phpstan-return is currently not allowed/expected (can be fixed as per my link above, or if my PR is merged first).
  2. I believe we still need a general @return that more tools (such as phpstorm) can understand (instead of the absurdly-generic-to-the-point-of-being-useless @return array).

Then there's the point about having @phpstan- and @psalm- annotations for consistency or preferring one over the other (or none). That's more of a "business decision" - but now is the best time to decide, before we end up with a mishmash that needs to be maintained.

@AJenbo
Copy link
Copy Markdown
Contributor Author

Wow can't belive this was almost a month ago, sorry for the long wait I have just been insanely busy with other things thinking I was going to update this one at the end of the day or next day repeatedly. Well it's done now, except for uuf6429's point 2 which i find contradicts the note about having both the complicated logic and very long comment split appart.

@AJenbo Anders Jenbo (AJenbo) marked this pull request as ready for review May 23, 2026 02:46
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.

4 participants