Skip to content

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

Merged
ondrejmirtes merged 1 commit into
phpstan:1.7.xfrom
rvanvelzen:redundant-condition-iterable-type-message
May 15, 2022
Merged

Prevent redundant messages about missing iterable types in conditional target/subject#1314
ondrejmirtes merged 1 commit into
phpstan:1.7.xfrom
rvanvelzen:redundant-condition-iterable-type-message

Conversation

@rvanvelzen

Copy link
Copy Markdown
Contributor

@rvanvelzen

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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