vscode-phpactor icon indicating copy to clipboard operation
vscode-phpactor copied to clipboard

Assignment based type inference for class fields

Open BladeMF opened this issue 4 years ago • 6 comments

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 avatar Dec 14 '20 06:12 BladeMF

I just noticed it workes in method scope: image

So just needed for fields then.

BladeMF avatar Dec 14 '20 06:12 BladeMF

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 :eyes:

dantleech avatar Dec 14 '20 08:12 dantleech

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?

BladeMF avatar Dec 14 '20 08:12 BladeMF

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

dantleech avatar Dec 14 '20 08:12 dantleech

I understand.

BladeMF avatar Dec 14 '20 08:12 BladeMF

I'd rather have the refactorings implemented than this.

BladeMF avatar Dec 14 '20 08:12 BladeMF