Closed dantleech closed 3 years ago
I've added the additional test cases to code-transform
I have become really unsure of having diagnostics enabled. I mean, phpstan
will tell me about undefined methods anyway, I really don't want blue or yellow or red squiggly lines under methods that phpactor can't resolve. I still support showing the action only on unresolvable methods though.
What I suggest is at least make it an option to turn those off. I, as a developer, am really bugged by squggly lines - phpstan
's underscores on MethodProphecy
methods drive me NUTS. What do you think?
What I suggest is at least make it an option to turn those off
You can turn them off: https://phpactor.readthedocs.io/en/master/reference/configuration.html#language-server-diagnostics-on-update but I guess you mean more granularly?
Yes, just these diagnostics - for generate method
. Do you have diagnostics where you work? VIM? Having all unknown methods underlined is basically what phpstan
does after a certain level.
I guess I can try it and see.
My whole point is that this can be annoying if there are a lot of objects whose types are not inferred correctly (or, all prophecies, for that matter) - your whole file could light up with no way to turn it off, but those would not be generatable methods (or those would not light up?).
I think just having the light bulb (code actions) showing up after you step on an unknown method will be enough. This is how Visual Studio (not Code) does all refactorings - it offers them after you've selected the code or stepped on the property or method. So nobody would expect phpactor
to highlight all possible generate method sites in the file in advance (which is diagnostics).
Yes we can proably remove the diagnostics or make them optional :)
Prophecised methods get underscored :-( I actually don't mind the diagnostics elsewhere for now, but here it is annoying.
ObjectProphecy
objects?I don't mind adding some mechanism to specific diagnostics. Generics AND an extension would solve this, but generics are still a long way away (I would need weeks of dedicated time probably)
Not sure what to do either. Probably a "turn off diagnostics for undefined methods" setting would be the easiest solution.
This PR updates the method generator to use the ne
MissingMethodFinder
and act on the entire document:@BladeMF note that as we no longer use the parser, the tests have been simplified, the deleted test cases could be moved to code-transform however.
I also notice that, at least for me, generating methods in a foreign class does not place the method in the correct place (probably the source or offset is being wrongly mapped).