Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent redundant messages about missing iterable types in conditional target/subject #1314

Conversation

rvanvelzen
Copy link
Contributor

@rvanvelzen
Copy link
Contributor Author

@ondrejmirtes the same can probably be said about "Generic type X in PHPDoc tag @return does not specify all template types of class Y: ..."?

Comment on lines +77 to +85
if ($type instanceof ConditionalType || $type instanceof ConditionalTypeForParameter) {
$iterablesWithMissingValueTypehint = array_merge(
$iterablesWithMissingValueTypehint,
$this->getIterableTypesWithMissingValueTypehint($type->getIf()),
$this->getIterableTypesWithMissingValueTypehint($type->getElse()),
);

return $type;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not overly excited by this. An alternative would be to get the resolved type, but that might skip over types that disappear after normalization.

@ondrejmirtes ondrejmirtes merged commit 21e9087 into phpstan:1.7.x May 15, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@rvanvelzen The same logic should be applied in getNonGenericObjectTypesWithGenericClass. I think you meant to suggest that but the message usually is 'Function %s() return type with generic %s does not specify its types: %s', not the one you wrote.

@rvanvelzen rvanvelzen deleted the redundant-condition-iterable-type-message branch May 17, 2022 09:51
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.

Redundant messages about conditional types
2 participants