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

Assignment based type inference for class fields #13

Open
BladeMF opened this issue Dec 14, 2020 · 6 comments
Open

Assignment based type inference for class fields #13

BladeMF opened this issue Dec 14, 2020 · 6 comments

Comments

@BladeMF
Copy link
Contributor

BladeMF commented Dec 14, 2020

It would be really helpful if type is inferred for variables based on assignment. In that case, because a value with a known type is assigned to $this->arg1, and because it has no explicit type declaration, its type should be known.
image

Of course @var comments should have the highest precedence.

@BladeMF
Copy link
Contributor Author

BladeMF commented Dec 14, 2020

I just noticed it workes in method scope:
image

So just needed for fields then.

@BladeMF BladeMF changed the title Assignment based type inference Assignment based type inference for class fields Dec 14, 2020
@dantleech
Copy link
Contributor

dantleech commented Dec 14, 2020

Yes - this is constructor property type inference - it was supported for a couple of years but then with the language server it caused an infinite loop and I had to remove it 👀

@BladeMF
Copy link
Contributor Author

BladeMF commented Dec 14, 2020

That is really unfortunate. It's not that I can't live with it, it's just none of my services have type hints :-( Probably with 7.4 that won't be needed?

@dantleech
Copy link
Contributor

Yes, I would put it back it's a a question of time and it's not trivial...

@BladeMF
Copy link
Contributor Author

BladeMF commented Dec 14, 2020

I understand.

@BladeMF
Copy link
Contributor Author

BladeMF commented Dec 14, 2020

I'd rather have the refactorings implemented than this.

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

No branches or pull requests

2 participants