Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Nov 4, 2022

No description provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tbh, I don't know why this test got more precise with this change :)

Copy link
Member

Choose a reason for hiding this comment

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

Because preg_replace is impacted by your changes. By using selectFromArgs, conditional return type is resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@staabm staabm marked this pull request as ready for review November 4, 2022 08:57
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

since strtr has multiple signatures, I had to use selectFromArgs() here.

Copy link
Member

Choose a reason for hiding this comment

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

Because preg_replace is impacted by your changes. By using selectFromArgs, conditional return type is resolved.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

Looking at the extension, could we replace it with stubs with conditional return types instead?

@staabm
Copy link
Contributor Author

staabm commented Nov 4, 2022

could we replace it with stubs with conditional return types instead?

I think we could, but it would be a rather complicated conditional, which needs to cover non-empty-string, non-falsey-string and array types, and even combine those logical across parameters subject and replace.

for strtr we would also need to incorporate the 2 function variants.. I don't feel this would lead to a readable stub-file.

@ondrejmirtes ondrejmirtes merged commit d91411b into phpstan:1.9.x Nov 4, 2022
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the non-es-strtr branch November 4, 2022 13:26
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