Hello,
I am interested in getting Psalm working in Nova; however, I’m not sure how to make it work. I have installed Psalm via composer and have installed the extension into Nova. However, the extension doesn’t show me any errors in the sidebar at all. I believe the extension is running since I can see some encouraging output in the extension console. Also, I know the Psalm library works since I can run it through the command line and it gives me lots of expected type errors for my test code.
Are there some path configurations I could be missing? I find it somewhat baffling that I can’t get it to show me any issues in Nova’s sidebar. I am running PHP 8.2.7, Nova 11.2 trial, and Psalm dev-master@2e8d575543c73bae8f9fd3ac46957699c0b90903.
Thanks,
Graceson
––––––––––––––––––––––––––––––––––––––
Here is my test code:
––––––––––––––––––––––––––––––––––––––
<?php
class Test
{
public function property(): string
{
return $this->foo;
}
/**
*
* @return bool
*/
public function variable()
–––––––––––––––––––––––––––––––––––––––––––––––––
Here is the output from running `./vendor/bin/psalm test.php`
–––––––––––––––––––––––––––––––––––––––––––––––––
ERROR: MixedInferredReturnType - test.php:5:33 - Could not verify return type 'string' for Test::property (see https://psalm.dev/047)
public function property(): string
ERROR: UndefinedThisPropertyFetch - test.php:7:16 - Instance property Test::$foo is not defined (see https://psalm.dev/041)
return $this->foo;
ERROR: MixedReturnStatement - test.php:7:16 - Could not infer a return type (see https://psalm.dev/138)
return $this->foo;
ERROR: MixedInferredReturnType - test.php:12:16 - Could not verify return type 'bool' for Test::variable (see https://psalm.dev/047)
* @return bool
ERROR: UndefinedVariable - test.php:16:16 - Cannot find referenced variable $bar (see https://psalm.dev/024)
return $bar;
ERROR: MixedReturnStatement - test.php:16:16 - Could not infer a return type (see https://psalm.dev/138)
return $bar;
––––––––––––––––––––––––––––––––––––––
Here is the output from the Extension Console:
––––––––––––––––––––––––––––––––––––––
Psalm[9:49:53.410000] {
"type" : 3,
"message" : "closing"
}
Psalm[9:49:53.410000] Shutting down...
Psalm[9:49:53.415000] {
"type" : 3,
"message" : "closed"
}
Psalm[9:49:53.663000] Psalm Language Server dev-master@2e8d575543c73bae8f9fd3ac46957699c0b90903 has started.
Psalm[9:49:53.683000] Initializing...
Psalm[9:49:53.683000] {
"message" : "initializing",
"type" : 3
}
Psalm[9:49:53.683000] Initializing: Visiting Autoload Files...
Psalm[9:49:54.276000] Initializing: Loading Reference Cache...
Psalm[9:49:54.285000] Initializing: Initialize Plugins...
Psalm[9:49:54.287000] Initializing: Getting code base...
Psalm[9:49:54.287000] {
"type" : 3,
"message" : "initializing: getting code base"
}
Psalm[9:49:54.287000] Initializing: Scanning files (8 Threads)...
Psalm[9:49:54.287000] {
"type" : 3,
"message" : "initializing: scanning files"
}
Psalm[9:49:54.287000] Initializing: Registering stub files...
Psalm[9:49:54.287000] {
"type" : 3,
"message" : "initializing: registering stub files"
}
Psalm[9:49:54.495000] Initializing: Complete.
Psalm[9:49:54.495000] {
"type" : 3,
"message" : "initialized"
}
Psalm[9:49:54.497000] {
"message" : "running",
"type" : 3
}
Hi Graceson,
Sorry for taking so long to reply, I've had a busy couple of months.
The extension works for me, and the logs you list in your email seem
fine to me, they're the same I see in projects I work on that use Psalm
and the extension works fine.
> I am running PHP 8.2.7, Nova 11.2 trial, and Psalm
dev-master@2e8d575543c73bae8f9fd3ac46957699c0b90903.
I'm using PHP 7.4.33, Nova 11.3 build 534827, and Psalm 4.13.1. Not sure
how outdated my Psalm version is, but that might be part of the problem.
Seems a bit unlikely though since the output from the extension console
seems fine.
When you open the file, which language is Nova configured to use for
that file? It should be set to "PHP". If you're using the "advanced PHP"
extension that may interfere with the Psalm extension working properly
since it creates a new language for PHP files.
Let me know if you keep running into issues and I'll try to dig a little
deeper.
Best regards,
Kristófer R.