branch: externals/phps-mode commit a6e68e2cd145bdef910c2654954621c352f0a6fd Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Improved bookkeeping of global declared variables in functional-oriented PHP --- phps-mode-lex-analyzer.el | 3 +-- phps-mode.el | 4 ++-- test/phps-mode-test-lex-analyzer.el | 7 +++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el index a14dceb..4846e4f 100644 --- a/phps-mode-lex-analyzer.el +++ b/phps-mode-lex-analyzer.el @@ -1342,8 +1342,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL." ;; In global variable declaration (when (and in-global-declaration - (equal token 'T_VARIABLE) - imenu-in-function-name) + (equal token 'T_VARIABLE)) (setq bookkeeping-in-assignment t)) ;; In static variable declaration diff --git a/phps-mode.el b/phps-mode.el index ed9ee79..099dd9a 100644 --- a/phps-mode.el +++ b/phps-mode.el @@ -5,8 +5,8 @@ ;; Author: Christian Johansson <christ...@cvj.se> ;; Maintainer: Christian Johansson <christ...@cvj.se> ;; Created: 3 Mar 2018 -;; Modified: 16 Oct 2020 -;; Version: 0.3.64 +;; Modified: 21 Oct 2020 +;; Version: 0.3.65 ;; Keywords: tools, convenience ;; URL: https://github.com/cjohansson/emacs-phps-mode diff --git a/test/phps-mode-test-lex-analyzer.el b/test/phps-mode-test-lex-analyzer.el index aafc658..16b1ae0 100644 --- a/test/phps-mode-test-lex-analyzer.el +++ b/test/phps-mode-test-lex-analyzer.el @@ -1553,6 +1553,13 @@ (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 39) 1) (" function test id $var" 1) ((54 58) 1) ((68 72) 1))))) + (phps-mode-test--with-buffer + "<?php\n\nglobal $a, $b;\n\nif ($a) {\n echo 'Hit';\n}\n\nfunction myFunction($c)\n{\n global $a;\n if ($a) {\n echo 'Hit';\n }\n if ($b) {\n echo 'Miss';\n }\n}\n" + "Bookkeeping of global variables in functional-oriented file" + (should (equal + (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) + '((" id $a" 1) ((15 17) 1) (" id $b" 1) ((19 21) 1) ((28 30) 1) (" function myFunction id $c" 1) ((73 75) 1) (" function myFunction id $a" 1) ((90 92) 1) ((102 104) 1) ((142 144) 0))))) + ) (defun phps-mode-test-lex-analyzer ()