Skip to content

[phpstorm-stubs] Add logic to resolve and normalize return types from PHPDoc in StubsTypeHintsTest#1826

Merged
LolGleb merged 6 commits intoJetBrains:masterfrom
LolGleb:fix_return_types
Dec 22, 2025
Merged

[phpstorm-stubs] Add logic to resolve and normalize return types from PHPDoc in StubsTypeHintsTest#1826
LolGleb merged 6 commits intoJetBrains:masterfrom
LolGleb:fix_return_types

Conversation

@LolGleb
Copy link
Copy Markdown
Contributor

@LolGleb LolGleb commented Dec 5, 2025

No description provided.

Comment thread tests/StubsTypeHintsTest.php Outdated
Comment thread tests/StubsTypeHintsTest.php
…type normalization logic in StubsTypeHintsTest
Comment thread tests/StubsTypeHintsTest.php Outdated
* @param array $types Array of strings with types for processing
* @return array Normalized types
*/
private static function processTypes(array $types): array
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.

IMO, process is quite a generic and not descriptive name here. How do we process types? AFAIU we convert a string of types to array of types and make them unified, right? Would something like convertToArrayOfUnifiedTypes or convertToArrayOfNormalizedTypes be more descriptive here?

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.

Yeah, you are right. Your variants are much more descriptive

Comment thread tests/StubsTypeHintsTest.php Outdated
$result[] = self::replaceArrayNotations($simpleType);
}

return array_filter(array_unique($result));
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.

Sorry, but I'm not sure I get why we need array_filter without a callback here?

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.

It was made to remove possible falsy elements like null, false, 0 etc.
But since tests pass even without it, I removed it

Comment thread tests/StubsTypeHintsTest.php Outdated
}

/**
* @param array $types Array of strings with types for processing
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.

Does it make sense to replace array with string[] here since we pass an array of strings, right?

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.

Yeah, we can do that

…tToArrayOfNormalizedTypes` and update references in StubsTypeHintsTest
@LolGleb LolGleb requested a review from isfedorov December 16, 2025 16:10
@LolGleb
Copy link
Copy Markdown
Contributor Author

LolGleb commented Dec 22, 2025

I take responsibility🫡

@LolGleb LolGleb merged commit 2a3e20f into JetBrains:master Dec 22, 2025
13 checks passed
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.

2 participants