branch: elpa/php-mode
commit 8491d67da76bbea22617dcd151cc938c7172b33e
Author: USAMI Kenta <[email protected]>
Commit: USAMI Kenta <[email protected]>

    Take php-executable from php-core instead of guessing at it
    
    php-project.el and php-flymake.el both wanted php-executable and
    neither could say so.  php.el requires php-project, so php-project
    requiring php.el back would have been circular, and php-flymake.el is
    pulled in by php-mode.el for the same reason.  Both worked around it by
    testing whether the variable happened to be bound:
    
        php-project.el:  ((boundp 'php-executable) php-executable)
                         (t (executable-find "php"))
        php-flymake.el:  (list (or (bound-and-true-p php-executable) "php"))
    
    php-core.el now holds php-executable and depends on nothing, so both can
    require it and ask for the variable directly.  No cycle: php-core
    requires nothing, and php.el already requires both php-core and
    php-project.
    
    This drops the fallback branches, which were only ever reached when
    php.el had not been loaded.  The single behaviour change is there: with
    no PHP installed, php-project-get-php-executable returned nil in that
    case and now returns "php".  That is what php-executable itself defaults
    to -- (or (executable-find "php") "php") -- so the two now agree instead
    of disagreeing.
---
 lisp/php-flymake.el |  3 ++-
 lisp/php-project.el | 11 +++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/php-flymake.el b/lisp/php-flymake.el
index 25ae9083ba..00bafba88d 100644
--- a/lisp/php-flymake.el
+++ b/lisp/php-flymake.el
@@ -27,6 +27,7 @@
 ;;; Code:
 (require 'flymake)
 (require 'cl-lib)
+(require 'php-core)
 (eval-and-compile
   (require 'flymake-proc))
 (eval-when-compile
@@ -101,7 +102,7 @@ See `flymake-diagnostic-functions' about REPORT-FN and ARGS 
parameters."
 (defun php-flymake--build-command-line (file)
   "Return the command line for `php -l' FILE."
   (let* ((command-args (or php-flymake-executable-command-args
-                           (list (or (bound-and-true-p php-executable) 
"php"))))
+                           (list php-executable)))
          (cmd (car-safe command-args))
          (default-directory (expand-file-name "~")))
     (unless (or (file-executable-p cmd)
diff --git a/lisp/php-project.el b/lisp/php-project.el
index 570c162dd1..e057b5fe6a 100644
--- a/lisp/php-project.el
+++ b/lisp/php-project.el
@@ -58,6 +58,7 @@
 ;;; Code:
 (eval-when-compile
   (require 'cl-lib))
+(require 'php-core)
 (require 'projectile nil t)
 
 ;; Constants
@@ -217,12 +218,10 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' 
and `psr2'.")
 
 (defun php-project-get-php-executable ()
   "Return path to PHP executable file."
-  (cond
-   ((and (stringp php-project-php-executable)
-         (file-executable-p php-project-php-executable))
-    php-project-php-executable)
-   ((boundp 'php-executable) php-executable)
-   (t (executable-find "php"))))
+  (if (and (stringp php-project-php-executable)
+           (file-executable-p php-project-php-executable))
+      php-project-php-executable
+    php-executable))
 
 (defun php-project-get-file-html-template-type (filename)
   "Return symbol T, NIL or `auto' by `FILENAME'."

Reply via email to