FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Keep traversing type when we can contain lowercase/upercase strings by VincentLanglet · Pull Request #3792 · phpstan/phpstan-src · GitHub

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

Merged
ondrejmirtes merged 2 commits into
phpstan:1.12.xfrom
VincentLanglet:fix/getRecommendedLevelByType
Jan 22, 2025
Merged

Keep traversing type when we can contain lowercase/upercase strings#3792
ondrejmirtes merged 2 commits into
phpstan:1.12.xfrom
VincentLanglet:fix/getRecommendedLevelByType

Conversation

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

But I added a test for the callable case
ad97094

ondrejmirtes merged commit d2e193c into phpstan:1.12.x Jan 22, 2025

Copy link
Copy Markdown
Member

Thank you!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL