[phpstorm-stubs] Add logic to resolve and normalize return types from PHPDoc in StubsTypeHintsTest#1826
Conversation
… PHPDoc in StubsTypeHintsTest
…ing return types from PHPDoc in StubsTypeHintsTest
…type normalization logic in StubsTypeHintsTest
| * @param array $types Array of strings with types for processing | ||
| * @return array Normalized types | ||
| */ | ||
| private static function processTypes(array $types): array |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Yeah, you are right. Your variants are much more descriptive
| $result[] = self::replaceArrayNotations($simpleType); | ||
| } | ||
|
|
||
| return array_filter(array_unique($result)); |
There was a problem hiding this comment.
Sorry, but I'm not sure I get why we need array_filter without a callback here?
There was a problem hiding this comment.
It was made to remove possible falsy elements like null, false, 0 etc.
But since tests pass even without it, I removed it
| } | ||
|
|
||
| /** | ||
| * @param array $types Array of strings with types for processing |
There was a problem hiding this comment.
Does it make sense to replace array with string[] here since we pass an array of strings, right?
There was a problem hiding this comment.
Yeah, we can do that
…tToArrayOfNormalizedTypes` and update references in StubsTypeHintsTest
|
I take responsibility🫡 |
No description provided.