-
Notifications
You must be signed in to change notification settings - Fork 15
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
Variable configure file #4
Conversation
Probably this change conflicts with #3. |
// Local Variables: | ||
// phpstan-config-file: (root . "tests/phpstan.neon") | ||
// phpstan-level: 7 | ||
// End: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is not automated, but we can check flycheck's behavior manually.
phpstan.el
Outdated
"analyze" | ||
"--no-progress" | ||
"--errorFormat=raw" | ||
:command ("php" (eval (phpstan-get-executable)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since phpstan
is generally a PHP script (or Phar archive), this command works fine. Therefore, it is not possible to specify shell scripts that are not PHP or "real" executables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a feature though? I run phpstan through docker so this would not work for me for example. And there are many people who do so as well: https://github.com/phpstan/docker-image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This problem was solved with the hack of phpstan-enabled-and-set-flycheck-variable
. It is an evil side effect.
phpstan.el
Outdated
|
||
;;;###autoload | ||
(progn | ||
(defvar phpstan-config-file nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason of having these as variables instead of flycheck options? The flycheck macro expands to a defcustom so we can still change it manually just as a defvar but it probides good documentation and listing of options for users.
phpstan.el
Outdated
#'(lambda (v) (or (null v) | ||
(integerp v) | ||
(and (stringp v) | ||
(string-match-p "\\`[1-9][0-9]*\\'" v)))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not match "0"
, why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. It fixed.
phpstan.el
Outdated
|
||
;;;###autoload | ||
(progn | ||
(defvar phpstan-executable nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flycheck defines a variable for this automatically. I guess the question is the same as for the variable above.
"Return path to phpstan configure file or `NIL'." | ||
(if phpstan-config-file | ||
(if (and (consp phpstan-config-file) | ||
(eq 'root (car phpstan-config-file))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not clear what the structure of phpstan-config-file
should be. I think user options should at least be defined as defcustoms with a type annotation.
phpstan.el
Outdated
"analyze" | ||
"--no-progress" | ||
"--errorFormat=raw" | ||
:command ("php" (eval (phpstan-get-executable)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a feature though? I run phpstan through docker so this would not work for me for example. And there are many people who do so as well: https://github.com/phpstan/docker-image
phpstan.el
Outdated
:command ("php" (eval (phpstan-get-executable)) | ||
"analyze" "--errorFormat=raw" "--no-progress" "--no-interaction" | ||
"-c" (eval (phpstan-get-config-file)) | ||
"-l" (eval (phpstan-get-level)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if these options eval to nil
, then the flag has no value and it errors out. The (option ..)
expansion flycheck uses takes care of that.
phpstan.el
Outdated
source) | ||
:working-directory (lambda (_) (php-project-get-root-dir)) | ||
:enabled (lambda () (locate-dominating-file "phpstan.neon" default-directory)) | ||
:enabled (lambda () (phpstan-get-config-file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this still doesn't work if I don't use any configuration file at all.
phpstan.el
Outdated
|
||
;;;###autoload | ||
(progn | ||
(defvar phpstan-config-file nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flycheck also provides the flycheck-def-config-file-var
macro for this
@Fuco1 First of all, since this package is
Your point is rational. However, I do not think that it is appropriate that project-specific settings depend on customization mechanisms. That is one reason why I did not depend on
This notation is not publicly specified, but I do not think that it is a remarkably esoteric notation by Emacs users. ......Uh, I know that my English sentences are not good. |
bfaf09e
to
0508372
Compare
This code needs to be refactored, but once it is merged into master it will be the first release. |
source) | ||
:working-directory (lambda (_) (php-project-get-root-dir)) | ||
:enabled (lambda () (locate-dominating-file "phpstan.neon" default-directory)) | ||
:command ("php" (eval (phpstan-get-command-args)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work when this starts "php"
but I set 'docker
as executable? Then the arguments are going to be run --rm -v...
, that won't work with php would it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fuco1 This is an insane hack.
phpstan-enabled-and-set-flycheck-variable
invoked as :enabled
function sets flycheck-phpstan-executable
as its side effect when flycheck-phpstan-executable
is not set. Since it uses the fact that :enabled
is called beforehand, there is a possibility that it will be destroyed in the future with low probability.
It was possible to explicitly write flycheck-phpstan-executable
in the user setting, but it was handled within this function as it is somewhat complicated. I am looking for ways to solve this problem besides this hack.
@zonuexe Thanks, I think your points are valid, if we want to support other mechanisms than flycheck then it makes sense to me. |
refs #2