Skip to content

Conversation

andersonamuller
Copy link

@andersonamuller andersonamuller commented Aug 13, 2025

When the config checkBenevolentUnionTypes is enabled the str_replace starts to always reporting the return as string|list<string> but in reality the return depends on the $subject param type.

@staabm
Copy link
Contributor

staabm commented Aug 13, 2025

which error is this PR trying to solve? can you reproduce the error/problem on phpstan.org/try ?

@andersonamuller
Copy link
Author

andersonamuller commented Aug 13, 2025

How can I create a try reproducible with the config checkBenevolentUnionTypes enabled?
https://phpstan.org/r/e850992d-7494-49b0-9ccb-0af488bd1710

@staabm
Copy link
Contributor

staabm commented Aug 13, 2025

I see. you cannot set a config flag on phpstan.org/try.

please add a test-case in ReturnTypeRuleTest which fails without your fix

@VincentLanglet
Copy link
Contributor

VincentLanglet commented Aug 30, 2025

For the record, the computed type is done in a dynamic return type extension and there is already a PR which does some improvement on it #4023

That might not solve your issue thought, but be aware of conflicts.
Also a reproducer would be good first.

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