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

Keep traversing type when we can contain lowercase/upercase strings #3792

Merged

Conversation

VincentLanglet
Copy link
Contributor

{
/** @var array{numeric-string} $b */
$b = $a;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need more tests for different variants of this problem?

like

Suggested change
}
}
/**
* @param array{numeric-string&uppercase-string&lowercase-string} $a
*/
public function sayUpper(array $a): void
{
/** @var array{uppercase-string} $b */
$b = $a;
}
/**
* @param array{numeric-string&uppercase-string&lowercase-string} $a
*/
public function sayLower(array $a): void
{
/** @var array{lowercase-string} $b */
$b = $a;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe also variants with non-empty-string, non-falsey-string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so since it's not related to numeric-string directly.

The issue was because it was a ConstantArray with a lowercase-string or upercase-string inside.
Because of the early return $type we didn't process the content of the array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I added a test for the callable case
ad97094

@ondrejmirtes ondrejmirtes merged commit d2e193c into phpstan:1.12.x Jan 22, 2025
451 of 452 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

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.

3 participants