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

"Flycheck cannot use this syntax checker for this buffer." #8

Open
MarTango opened this issue May 4, 2018 · 8 comments
Open

"Flycheck cannot use this syntax checker for this buffer." #8

MarTango opened this issue May 4, 2018 · 8 comments

Comments

@MarTango
Copy link

MarTango commented May 4, 2018

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

@MarTango
Copy link
Author

MarTango commented May 4, 2018

Using vendor/bin/phpstan analyse src works as expected

@kermorgant
Copy link
Contributor

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))))

@kermorgant
Copy link
Contributor

kermorgant commented May 17, 2018

just noticed that adding/removing the specific line below makes a difference

         (phpstan-config-file . (root . "./phpstan.neon"))

@MarTango
Copy link
Author

MarTango commented May 17, 2018 via email

@cyrialize
Copy link

What is the significance of phpstan.neon? Is that an automatically generated file?

@kermorgant
Copy link
Contributor

It's phpstan's configuration file

@kermorgant
Copy link
Contributor

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 ?

@olapersson
Copy link

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.

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

4 participants