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

return type not inferred #8181

Closed
staabm opened this issue Sep 6, 2023 · 4 comments · Fixed by rectorphp/rector-src#4919
Closed

return type not inferred #8181

staabm opened this issue Sep 6, 2023 · 4 comments · Fixed by rectorphp/rector-src#4919
Labels

Comments

@staabm
Copy link
Contributor

staabm commented Sep 6, 2023

Feature Request

https://getrector.com/demo/905228f9-7d32-4aa3-9895-7071b3d6ff83

I wonder why rector is not able to infer the string return type

@staabm staabm added the feature label Sep 6, 2023
@samsonasik
Copy link
Member

PHPStan seems detect variable $style in last rerun as error type, see https://phpstan.org/r/ea1c7a84-2be8-44bf-913d-f1b8e0db64dd

@samsonasik
Copy link
Member

@staabm I created PHPStan issue at phpstan/phpstan#9855

@staabm
Copy link
Contributor Author

staabm commented Sep 6, 2023

Thx. Seems its a autoloading issue then. I need to check class loading rules.

But I still got an idea from this conversation. Maybe we can have a rector which replaces the variable return with a constant value return when phpstan is able to narrow the variable type to a single constant value?

@samsonasik
Copy link
Member

I discussed with Ondre, it seems the type when class and method exists, it got ConstantStringType, that may need to be checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants