https://github.com/vimeo/psalm/commit/fec1a60e90b37d757d929cc5b0e776fdaeb9b8c1 has really improved my experience using VS Code together with Psalm's Language Server. The experience is pretty awesome. What I'm missing however is auto complete suggestions when param types have been inferred.
For example
$dates = [LocalDate::of(2015, 1, 1), LocalDate::of(2017, 8, 2)];
array_map(function (LocalDate $date) {
// VS code provides auto complete suggestions based on LocalDate class definition
$date->
}, $dates);
array_map(function ($date) {
// No auto complete suggestions, even though Psalm has inferred that $date is instance of LocalDate
$date-> ...
}, $dates);
This is currently blocked by https://github.com/nikic/PHP-Parser/issues/545.
I have a hacky workaround, and the code exists to provide responses, but I decided not to enable it in the language server because of the aforementioned hack (which involves reparsing a document without -> to see if that's the only breaking thing.
I could make autocompletion optional (i.e. a feature flag) - would that interest you? In that scenario I probably wouldn't work on it, but would be happy to accept PRs.
@muglug Shouldn't the shown example cases work, as they're followed by } rather than an if or similar?
I could make autocompletion optional (i.e. a feature flag) - would that interest you? In that scenario I probably wouldn't work on it, but would be happy to accept PRs.
Yeah, I'd love to give that a go.
@nikic yeah those cases do work, but I didn't feel confident enough in my hack for the if scenario to release autocompletion as a feature.
You can now use --enable-autocomplete argument in the language server for method/property autocomplete suggestions
Most helpful comment
You can now use
--enable-autocompleteargument in the language server for method/property autocomplete suggestions