SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
37 stars 7 forks source link

Issue with phpstan-doctrine #59

Closed michalblocinski closed 4 months ago

michalblocinski commented 4 months ago

I have an issue using phpstan-doctrine and phpstan-vscode extension. This is my phpstan.neon:

includes:
    - vendor/phpstan/phpstan-doctrine/extension.neon
    - vendor/phpstan/phpstan-doctrine/rules.neon
parameters:
    level: 9
    paths:
        - src
        - tests
    checkMissingIterableValueType: false
    ignoreErrors:
        - '#Method .+::dispatch\(\) invoked with 2 parameters, 1 required\.#'
        - '#Method .+ return type has no value type specified in iterable type .+#'
        - '#Method .+ has parameter .+ with no value type specified in iterable type array\.#'
        - '#Property .+::\$id is never written, only read\.#'
    stubFiles:
        - app/stubs/Symfony.stub
        - app/stubs/Filter.stub
        - app/stubs/json.stub
    doctrine:
        objectManagerLoader: app/stubs/object-manager.php

And when I run it this way via cli: <path>/phpstan analyse <path>/Repository.php -c <path>/phpstan.neon it will return list of errors. But when I use it as extension it does not report errors. This is output log:

[check:35] Spawning PHPStan with the following configuration:  {"binCmd":"<path>/phpstan","args":["analyse","-c","<path>/phpstan.neon","--error-format=raw","--no-interaction","--memory-limit=1G","--no-progress","<path>/Repository.php","-a","/var/folders/54/7q9csvqd5_qfg91kt6j_jklc0000gn/T/tmp-1004-LXYhMyo2G3LR/autoload.php","-c","/var/folders/54/7q9csvqd5_qfg91kt6j_jklc0000gn/T/tmp-1004-LXYhMyo2G3LR/config.neon"]}
[check:34] Check completed for file:///<path>/Repository.php errors= {}

I would expect same response to be for command via cli as well via extension Additional information is that if I remove this part from phpstan.neon configuration:

doctrine:
        objectManagerLoader: app/stubs/object-manager.php

Extension again show errors correctly

SanderRonde commented 4 months ago

Can you check out the contents of the temporary config.neon file? Does it look OK or is there some stuff missing? Is there any special output if you run the check with the configuration in the log (so with the overridden config.neon)? Try removing --error-format=raw and --no-progress lines if nothing useful comes up.

Alternatively you could try disabling the language server (phpstan.enableLanguageServer setting), that may very well fix it too Or alternatively

michalblocinski commented 4 months ago

@SanderRonde setting Phpstan: Enable Language Server option to false in settings fixed the issue. How to get overridden config.neon? I don't know because when I try this file after vsconfig execute phpstan temporary config.neon is removed

SanderRonde commented 4 months ago

Ahh yeah if it's immediately removed then that's pretty much impossible but thanks for giving it a try. If it's not easy to do that then let's just leave it for now. Glad to hear the issue was fixed by disabling the setting though. I think it causes such issues quite often so I might consider disabling it by default...

In any case, I think this issue is resolved then right? Please let me know if you need further help.