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

Add ArrayChangeKeyCaseFunctionReturnTypeExtension #3549

Merged
merged 7 commits into from
Jan 16, 2025

Conversation

VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Oct 7, 2024

@VincentLanglet VincentLanglet force-pushed the arrayChangeKeyCase branch 2 times, most recently from 615c172 to 461b22d Compare October 7, 2024 19:48
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet VincentLanglet requested a review from staabm October 7, 2024 21:50
@VincentLanglet VincentLanglet requested a review from staabm October 8, 2024 07:50
Copy link
Contributor

@staabm staabm left a comment

Choose a reason for hiding this comment

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

lgtm - thanks

@VincentLanglet
Copy link
Contributor Author

I updated the PR to also support uppercase-string @ondrejmirtes

foreach ($constantArrays as $constantArray) {
$newConstantArrayBuilder = ConstantArrayTypeBuilder::createEmpty();
foreach ($constantArray->getKeyTypes() as $i => $keyType) {
$valueType = $constantArray->getOffsetValueType($keyType);
Copy link
Member

Choose a reason for hiding this comment

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

Calling getOffsetValueType is too expensive. You can $valueTypes = $constantArray->getValueTypes() and then access $i to get it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

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

Thank you.

@ondrejmirtes
Copy link
Member

Would be nice to add a similar extension for mb_convert_case, would you look into it? Context: phpstan/phpstan#12452

Thanks!

@VincentLanglet
Copy link
Contributor Author

Would be nice to add a similar extension for mb_convert_case, would you look into it? Context: phpstan/phpstan#12452

Thanks!

Do you have a reproducer ?

Because, for me, the mb_convert_case extension is handled by

And we can see in the history that it was handled for lowercase-string and upper-case string
https://github.com/phpstan/phpstan-src/commits/e2b5a60fa52460ba3addd519b07e2244809878ee/src/Type/Php/StrCaseFunctionsReturnTypeExtension.php

@ondrejmirtes
Copy link
Member

I'm sorry, I haven't checked personally and trusted the user. PHPStan already handles it well https://phpstan.org/r/fad685d0-5331-4af2-8bb9-d0d1a0f81d00.

@VincentLanglet
Copy link
Contributor Author

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.

4 participants