phpstan.el
phpstan.el copied to clipboard
"Flycheck cannot use this syntax checker for this buffer."
Relevant lines in my init.el:
(defun my/php-mode-hook ()
"Gets run on php-mode load."
(make-local-variable 'company-backends)
(add-to-list 'company-backends 'company-phpactor)
(flycheck-select-checker 'phpstan)
(setq php-mode-coding-style 'psr2
c-basic-offset 4)
(when (eq 0 (buffer-size))
(insert "<?php\n\n")))
(use-package php-mode :ensure t
:init (add-hook 'php-mode-hook #'my/php-mode-hook))
(use-package flycheck-phpstan :ensure t :after (php-mode flycheck))
The buffer that appears when I open PHP file:
Syntax checker in buffer MyFile.php in php-mode:
phpstan (disabled)
- major mode: `php-mode' supported
- may enable: Automatically disabled!
- executable: Found at /usr/local/bin/php
Flycheck cannot use this syntax checker for this buffer.
Flycheck Mode is enabled. Use C-u C-c ! x to enable disabled
checkers.
--------------------
Flycheck version: 32snapshot (package: 20180422.2106)
Emacs version: 26.1
System: x86_64-apple-darwin17.5.0
Window system: ns
PHPStan Project Version - installed using project's composer.
PHPStan - PHP Static Analysis Tool dev-master@de7fd7d
Using vendor/bin/phpstan analyse src
works as expected
I've stumbled on the same issue several times. Haven't taken time to really look into it, but adding project specific configuration like below have often helped
((nil . ((php-project-root . git)
(phpstan-executable . "/home/mikael/bin/phpstan")
(phpstan-working-dir . (root . "."))
(phpstan-config-file . (root . "./phpstan.neon"))
(phpstan-level . 7))))
just noticed that adding/removing the specific line below makes a difference
(phpstan-config-file . (root . "./phpstan.neon"))
Ah. I've only tried out the package (and phpstan) on a project without a config file - might be why it's not working
On Thu, 17 May 2018, 20:14 Mikael Kermorgant, [email protected] wrote:
just noticed that the specific line below makes a difference
(phpstan-config-file . (root . "./phpstan.neon"))
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/emacs-php/phpstan.el/issues/8#issuecomment-389977881, or mute the thread https://github.com/notifications/unsubscribe-auth/AMwKu4g9L4bdEbJtt_8YMp8y-YqIu5aVks5tzcwzgaJpZM4Tyr8v .
What is the significance of phpstan.neon? Is that an automatically generated file?
It's phpstan's configuration file
I'm not sure of how I should read the code but I suspect this issue takes its root somewhere around that part.
@zonuexe do I understand correctly the situation when I say a phpstan config file is required ?
Spent some time with the same error, in my case I was trying to use a leading .
in the config file (.phpstan.neon
), removing the dot made things work.