Open kapitanluffy opened 1 month ago
I've found that generally it seems quite buggy. Right this very moment it outright refuses to lint, and even enabling debug mode for SublimeLinter doesn't show any information why it wouldn't be able to. Besides that, every so often I have to remove the package and reinstall it to resolve other such weird behaviour.
I've found that generally it seems quite buggy. Right this very moment it outright refuses to lint, and even enabling debug mode for SublimeLinter doesn't show any information why it wouldn't be able to. Besides that, every so often I have to remove the package and reinstall it to resolve other such weird behaviour.
You probably face the same problem as me with the new setting enable_cells
in Sublime Linter 4.26 released last week.
Please see my PR here.
Unless the fix is finally merged, do not install this plugin through Package Control
, but by cloning my fork in ~/Library/Application Support/Sublime Text/Packages
, and then it should be ok.
cd ~/Library/Application Support/Sublime Text/Packages
git clone https://github.com/pierresh/SublimeLinter-contrib-phpstan
My issues with stuff randomly not linting have actually existed for well over a year, perhaps even two. Note though that equally randomly it starts working again, as long as I've reinstalled this package at least once. Your fix does seem to work for the problem this time around, so at least my development flow has been restored now.
Seems like this project is kinda dead though. You opened your PR well over a year ago and there hasn't even been a single response. Perhaps you could contact Package Control and maintain your fork as the new current version? Dunno if you'd want to do so (or if Package Control would just let you take over like that), but otherwise I don't think many people will have a functional phpstan linter.
My issues with stuff randomly not linting have actually existed for well over a year, perhaps even two. Note though that equally randomly it starts working again, as long as I've reinstalled this package at least once. Your fix does seem to work for the problem this time around, so at least my development flow has been restored now.
Seems like this project is kinda dead though. You opened your PR well over a year ago and there hasn't even been a single response. Perhaps you could contact Package Control and maintain your fork as the new current version? Dunno if you'd want to do so (or if Package Control would just let you take over like that), but otherwise I don't think many people will have a functional phpstan linter.
No worry, I will keep maintaining at least my PR. I love too much Sublime Text, PHP and PHPStan to do not do so. Hopefully, @Rockstar04 would add me as a "Collaborator" in this repo and grant me the privilege to merge :)
Thanks a lot @Rockstar04 for the merge privilege :)
@kapitanluffy please provide the relation section of your PHP code, I will try to reproduce your bug. Currently, I do not find any problem.
@pierresh here is the minimum reproducible code
<?php
namespace MyApp;
class MyClass implements \JsonSerializable
{
public function jsonSerialize()
{
}
}
PHP version is 8.2.21
I am not sure what is happening on your computer because for me it works fine, I get warnings from both Intelephense and PHPStan.
@pierresh I'm not entirely sure if this is related to the original problem (looks quite the same to me at least), but once again I'm not getting any linting results. Running phpstan via CLI reports an error just fine (something about using $foo?->bar
in conjunction with ??
being unnecessary), but Sublime Text doesn't report any errors whatsoever. The code itself runs perfectly fine through PHP itself, so it's not like it would be unparseable altogether.
I enabled debug mode for SublimeLinter and it still doesn't really report anything useful:
SublimeLinter: sublime_linter.py:334 Delay linting 'my_script.php' for 0.1s
SublimeLinter: linter.py:1148 annotations: Checking lint mode 'background' vs lint reason 'on_modified'. Ok.
SublimeLinter: sublime_linter.py:334 Delay linting 'my_script.php' for 0.0s
SublimeLinter: linter.py:1148 annotations: Checking lint mode 'background' vs lint reason 'on_save'. Ok.
SublimeLinter: linter.py:1148 eslint: Checking lint mode 'background' vs lint reason 'on_save'. Ok.
SublimeLinter: linter.py:1148 phpstan: Checking lint mode 'background' vs lint reason 'on_save'. Ok.
SublimeLinter: #12246 linter.py:1165 eslint: linting 'my_script.php'
SublimeLinter: #12245 linter.py:1165 annotations: linting 'my_script.php'
SublimeLinter: #12246 node_linter.py:93 Searching executable for 'eslint' starting at '/Users/gottemhams/git/someproject'.
SublimeLinter: #12247 linter.py:1165 phpstan: linting 'my_script.php'
SublimeLinter: #12245 linter.py:1248 annotations: output:
something so SublimeLinter will not assume this view to be `ok`
SublimeLinter: #12246 linter.py:153 package.json did not contain dependencies or devDependencies required to lint this file type. Manually set 'selector' to override this behavior, or install the required dependencies.
SublimeLinter: backend.py:283 Linting 'my_script.php' with phpstan took 0.01s
SublimeLinter: backend.py:283 Linting 'my_script.php' with eslint took 0.01s
SublimeLinter: backend.py:283 Linting 'my_script.php' with annotations took 0.01s
Clearly it does try to lint with phpstan. I already tried removing and reinstalling the package (once again) but this time it doesn't seem to help. I don't know how to get more debug information out of SublimeLinter though.
I am not sure how the communication between PHPStan and SublimeLinter works.
Currently, this plugin runs when the file is opened or saved. I am trying to adjust it to run whenever a change is made, so we can see the linting results in real time. However, although the plugin is being executed when I made changes, the linter display is not refreshing, and I don’t understand why. It might be a problem with SublimeLinter.
I suggest trying to profile the plugin’s execution. To do this, uninstall the plugin if you installed it through Package Control. Then, clone the repository into ~/Library/Application Support/Sublime Text/Packages
. After that, you can modify the linter.py file by adding some print('here')
statements. These messages will be visible in Sublime Text’s console.
If you confirm that the plugin executes up to line 55 return cmd + ["${args}"] + opts + ["--", "${file}"]
, then the issue might be more related to SublimeLinter than to the plugin itself.
I'll have to check that next time, looks like it decided to behave again (for now at least).
I thought about one point: currently the plugin uses the global phpstan
executable. Maybe you have an old global version or something like this.
As now this plugin has the capability to resolve the file composer.json
, I adjusted my fork to use /vendor/bin/phpstan
instead of the global executable, then I believe the executable would be more up to date, and this sounds to be a better approach anyway.
You might have a try:
cd ~/Library/Application Support/Sublime Text/Packages
git clone https://github.com/pierresh/SublimeLinter-contrib-phpstan
Good point, unfortunately I actually already configured the linter to use the executable invendor
. Otherwise it would indeed scan with an older version and not give me the same results as for other people.
hello @GottemHams @kapitanluffy,
I reviewed the code of this plugin completely, I figured out that most of its code was dealing with legacy settings (initially it could not handle phpstan.neon
and vendor/autoload.php
).
I believe that in 2024, most of PHP projects have phpstan.neon
and vendor/autoload.php
in their root folder, thus, as this plugin can safely load them, I think we can completely discard management of legacy settings and simply rely on phpstan.neon
and vendor/autoload.php
.
I did a commit this morning and the code is much shorter and cleaner, thus more reliable.
You can test it can by uninstalling your current plugin, and then clone this repo as follow:
cd ~/Library/Application Support/Sublime Text/Packages
git clone https://github.com/Rockstar04/SublimeLinter-contrib-phpstan
I turned on debug and ran the command shown in Sublime's console and it showed an error but in Sublime, it says no output
You can reproduce this by implementing
jsonSerializable
and removing themixed
return type onjsonSerialize