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

Language Server: Autocomplete for PHPUnit #5210

Closed
thbley opened this issue Feb 12, 2021 · 4 comments
Closed

Language Server: Autocomplete for PHPUnit #5210

thbley opened this issue Feb 12, 2021 · 4 comments

Comments

@thbley
Copy link
Contributor

thbley commented Feb 12, 2021

I'm using psalm-vscode-plugin v1.2.2 with vs-code 1.52.1 / 1.53.0 (and code-server 3.8.1) and tried to get auto-complete working for phpunit 9.5.2 (loaded as composer library). E.g. $this->assertTrue() cannot be autocompleted from PHPUnit\Framework\TestCase -> PHPUnit\Framework\Assert.
When I type $this->assertTrue() manually, detecting invalid parameters works.

107127636-b6cb1b00-68b7-11eb-86d5-db5a6e398fae

107127639-bd599280-68b7-11eb-9d46-1fdb24eb79e2

I'm not sure it's related to psalm-vscode-plugin or psalm itself, so I also reported this in psalm/psalm-vscode-plugin#34 .

Happens with psalm 4.4.1 and psalm 4.5.1

@psalm-github-bot
Copy link

Hey @thomasbley, can you reproduce the issue on https://psalm.dev ?

@thbley
Copy link
Contributor Author

thbley commented Feb 15, 2021

I think I found my issue:

assertTrue is defined as static: public static function assertTrue().

But I call it in class context $this->assertTrue() as advised by the documentation https://phpunit.readthedocs.io/en/9.5/assertions.html#asserttrue

A change could be this, but I'm not sure it's good for all cases:

+++ b/src/Psalm/Codebase.php
@@ -1497,16 +1497,10 @@ class Codebase
             }
         }
 
-        if ($gap === '->') {
-            $completion_items = $instance_completion_items;
-        } else {
-            $completion_items = array_merge(
-                $instance_completion_items,
-                $static_completion_items
-            );
-        }
-
-        return $completion_items;
+        return array_merge(
+            $instance_completion_items,
+            $static_completion_items
+        );

What do you think about it?

@muglug
Copy link
Collaborator

muglug commented Feb 27, 2021

Sorry, again. This is fixed.

@muglug muglug closed this as completed Feb 27, 2021
@thbley
Copy link
Contributor Author

thbley commented Feb 27, 2021

No problem, thanks for fixing this issue!

This was referenced Mar 15, 2021
This was referenced Mar 17, 2021
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