branch: externals/phps-mode commit d5437507eead4229a2468edff07f415411000fd5 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Improved bookkeeping about class methods, variable references and array variable declarations --- phps-mode-lex-analyzer.el | 156 +++++++++++++++++++----------------- phps-mode.el | 4 +- test/phps-mode-test-lex-analyzer.el | 45 ++++++++--- 3 files changed, 117 insertions(+), 88 deletions(-) diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el index 316ba68..79d02df 100644 --- a/phps-mode-lex-analyzer.el +++ b/phps-mode-lex-analyzer.el @@ -116,44 +116,29 @@ "Clear region of syntax coloring from START to END." (with-silent-modifications (set-text-properties start end nil))) -(defun phps-mode-lex-analyzer--get-token-syntax-color (token &optional previous-token previous2-token) - "Return syntax color for TOKEN and optionally PREVIOUS-TOKEN and PREVIOUS2-TOKEN." +(defun phps-mode-lex-analyzer--get-token-syntax-color (token) + "Return syntax color for TOKEN." ;; Syntax coloring ;; see https://www.gnu.org/software/emacs/manual/html_node/elisp/Faces-for-Font-Lock.html#Faces-for-Font-Lock (let* ((start (car (cdr token))) (end (cdr (cdr token))) - (token-name (car token)) - (previous-token-name) - (previous2-token-name) - (previous2-token-contents)) - - ;; Catch contexts like $this->abc - (when (and - (equal token-name 'T_STRING) - previous-token - previous2-token) - (setq previous-token-name (car previous-token)) - (setq previous2-token-name (car previous2-token)) - (when (and - (equal previous-token-name 'T_OBJECT_OPERATOR) - (equal previous2-token-name 'T_VARIABLE)) - (setq previous2-token-contents (downcase (buffer-substring-no-properties (car (cdr previous2-token)) (cdr (cdr previous2-token))))))) + (bookkeeping-index (list start end)) + (token-name (car token))) ;; (message "Color token %s %s %s" token-name start end) (cond - ((or (equal token-name 'T_VARIABLE) - (and - (equal token-name 'T_STRING) - (equal previous-token-name 'T_OBJECT_OPERATOR) - (equal previous2-token-name 'T_VARIABLE) - (string= previous2-token-contents "$this"))) - (let ((bookkeeping-index (list start end))) - (if (gethash bookkeeping-index phps-mode-lex-analyzer--bookkeeping) + ((and (or (equal token-name 'T_VARIABLE) + (equal token-name 'T_STRING)) + (gethash bookkeeping-index phps-mode-lex-analyzer--bookkeeping)) + (let ((bookkeeping (gethash bookkeeping-index phps-mode-lex-analyzer--bookkeeping))) + (if (> bookkeeping 0) (list 'font-lock-face 'font-lock-variable-name-face) (list 'font-lock-face 'font-lock-warning-face)))) - ((equal token-name 'T_STRING_VARNAME) + ((or + (equal token-name 'T_VARIABLE) + (equal token-name 'T_STRING_VARNAME)) (list 'font-lock-face 'font-lock-variable-name-face)) ((equal token-name 'T_COMMENT) @@ -332,24 +317,20 @@ old-start phps-mode-lex-analyzer--tokens (point-max))) - (let ((previous-token) - (previous2-token)) - (dolist (token phps-mode-lex-analyzer--tokens) - (let ((start (car (cdr token))) - (end (cdr (cdr token))) - (token-name (car token))) - - ;; Apply syntax color on token - (let ((token-syntax-color - (phps-mode-lex-analyzer--get-token-syntax-color token previous-token previous2-token))) - (if token-syntax-color - (phps-mode-lex-analyzer--set-region-syntax-color start end token-syntax-color) - (phps-mode-lex-analyzer--clear-region-syntax-color start end))) - (setq previous2-token previous-token) - (setq previous-token token) - - (semantic-lex-push-token - (semantic-lex-token token-name start end))))) + (dolist (token phps-mode-lex-analyzer--tokens) + (let ((start (car (cdr token))) + (end (cdr (cdr token))) + (token-name (car token))) + + ;; Apply syntax color on token + (let ((token-syntax-color + (phps-mode-lex-analyzer--get-token-syntax-color token))) + (if token-syntax-color + (phps-mode-lex-analyzer--set-region-syntax-color start end token-syntax-color) + (phps-mode-lex-analyzer--clear-region-syntax-color start end))) + + (semantic-lex-push-token + (semantic-lex-token token-name start end)))) (setq semantic-lex-end-point (point-max))) @@ -417,17 +398,13 @@ (phps-mode-lex-analyzer--reset-imenu) ;; Apply syntax color on tokens - (let ((previous-token) - (previous2-token)) - (dolist (token phps-mode-lex-analyzer--tokens) - (let ((start (car (cdr token))) - (end (cdr (cdr token)))) - (let ((token-syntax-color (phps-mode-lex-analyzer--get-token-syntax-color token previous-token previous2-token))) - (if token-syntax-color - (phps-mode-lex-analyzer--set-region-syntax-color start end token-syntax-color) - (phps-mode-lex-analyzer--clear-region-syntax-color start end)))) - (setq previous2-token previous-token) - (setq previous-token token))))))) + (dolist (token phps-mode-lex-analyzer--tokens) + (let ((start (car (cdr token))) + (end (cdr (cdr token)))) + (let ((token-syntax-color (phps-mode-lex-analyzer--get-token-syntax-color token))) + (if token-syntax-color + (phps-mode-lex-analyzer--set-region-syntax-color start end token-syntax-color) + (phps-mode-lex-analyzer--clear-region-syntax-color start end))))))))) (lambda(result) (when (get-buffer buffer-name) @@ -515,19 +492,15 @@ (phps-mode-lex-analyzer--reset-imenu) ;; Apply syntax color on tokens - (let ((previous-token) - (previous2-token)) - (dolist (token phps-mode-lex-analyzer--tokens) - (let ((start (car (cdr token))) - (end (cdr (cdr token)))) - - ;; Apply syntax color on token - (let ((token-syntax-color (phps-mode-lex-analyzer--get-token-syntax-color token previous-token previous2-token))) - (if token-syntax-color - (phps-mode-lex-analyzer--set-region-syntax-color start end token-syntax-color) - (phps-mode-lex-analyzer--clear-region-syntax-color start end)))) - (setq previous2-token previous-token) - (setq previous-token token))) + (dolist (token phps-mode-lex-analyzer--tokens) + (let ((start (car (cdr token))) + (end (cdr (cdr token)))) + + ;; Apply syntax color on token + (let ((token-syntax-color (phps-mode-lex-analyzer--get-token-syntax-color token))) + (if token-syntax-color + (phps-mode-lex-analyzer--set-region-syntax-color start end token-syntax-color) + (phps-mode-lex-analyzer--clear-region-syntax-color start end))))) (phps-mode-debug-message (message "Incremental tokens: %s" phps-mode-lex-analyzer--tokens)))))) @@ -1087,6 +1060,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL." (special-control-structure-started-this-line nil) (temp-pre-indent nil) (temp-post-indent nil) + (array-variable-declaration nil) (imenu-index '()) (imenu-namespace-index '()) (imenu-class-index '()) @@ -1174,7 +1148,10 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL." ;; $this->... (equal token 'T_STRING) (equal previous-token 'T_OBJECT_OPERATOR) - (equal previous2-token 'T_VARIABLE))) + (equal previous2-token 'T_VARIABLE) + (not (or + (equal next-token "(") + (equal next-token "["))))) (let ((bookkeeping-namespace namespace) (bookkeeping-index (list token-start token-end)) @@ -1237,7 +1214,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL." (when imenu-in-class-name (let ((bookkeeping-method-this (concat bookkeeping-namespace " id $this"))) (unless (gethash bookkeeping-method-this bookkeeping) - (puthash bookkeeping-method-this t bookkeeping))))) + (puthash bookkeeping-method-this 1 bookkeeping))))) ;; Anonymous function level (when in-anonymous-function-nesting-level @@ -1263,7 +1240,14 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL." (equal previous2-token 'T_FOREACH))) (setq bookkeeping-in-assignment t)) - ;; Support foreach as $key => value + ;; Support stuff like foreach ($items as &$key)... + (when (and + (equal token 'T_VARIABLE) + (equal previous2-token 'T_AS) + (equal previous-token "&")) + (setq bookkeeping-in-assignment t)) + + ;; Support foreach ($items as $key => $value)... (when (and (equal token 'T_VARIABLE) (equal previous3-token 'T_AS) @@ -1272,6 +1256,15 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL." (string= next-token ")")) (setq bookkeeping-in-assignment t)) + ;; Support foreach ($items as $key => &$value)... + (when (and + (equal token 'T_VARIABLE) + (equal previous3-token 'T_VARIABLE) + (equal previous2-token 'T_DOUBLE_ARROW) + (equal previous-token "&") + (string= next-token ")")) + (setq bookkeeping-in-assignment t)) + ;; Stand-alone variable assignment (when (and (equal token 'T_VARIABLE) first-token-on-line @@ -1300,6 +1293,12 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL." (equal token 'T_VARIABLE)) (setq bookkeeping-in-assignment t)) + ;; In [$abc, $def] = .. or array($abc, $def) = ... + (when (and + array-variable-declaration + (equal token 'T_VARIABLE)) + (setq bookkeeping-in-assignment t)) + ;; Class variables (when (and imenu-in-class-name @@ -1325,17 +1324,24 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL." (if bookkeeping-is-superglobal ;; Super-globals always hit - (puthash bookkeeping-index t bookkeeping) + (puthash bookkeeping-index 1 bookkeeping) ;; Check scoped variable (if (gethash bookkeeping-namespace bookkeeping) (progn (phps-mode-debug-message (message "Bookkeeping-hit: %s" bookkeeping-index)) - (puthash bookkeeping-index t bookkeeping)) + (puthash bookkeeping-index 1 bookkeeping)) (phps-mode-debug-message (message "Bookkeeping-miss: %s" bookkeeping-index)) - (puthash bookkeeping-index nil bookkeeping))))) + (puthash bookkeeping-index 0 bookkeeping))))) + + ;; Keep track of array variable declaration + (when first-token-on-line + (if (or (equal token 'T_ARRAY) + (equal token "[")) + (setq array-variable-declaration t) + (setq array-variable-declaration nil))) ;; Keep track of open catch blocks for bookkeeping (when (equal token 'T_CATCH) diff --git a/phps-mode.el b/phps-mode.el index e12dcb1..0570936 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: 11 Sep 2020 -;; Version: 0.3.54 +;; Modified: 14 Sep 2020 +;; Version: 0.3.55 ;; 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 8712414..0b8305d 100644 --- a/test/phps-mode-test-lex-analyzer.el +++ b/test/phps-mode-test-lex-analyzer.el @@ -1359,64 +1359,87 @@ "Bookkeeping in root level variable assignments #1." (should (equal (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list " id $var" 1) (list (list 8 12) t) (list (list 27 32) nil) (list (list 73 77) t))))) + (list (list " id $var" 1) (list (list 8 12) 1) (list (list 27 32) 0) (list (list 73 77) 1))))) (phps-mode-test--with-buffer "<?php\n\n$var = 'abc';\n\nif ($var) {\n echo 'This never happens';\n}\nif ($var2) {\n echo 'This happens';\n}" "Bookkeeping in root level variable assignments #2." (should (equal (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list " id $var" 1) (list (list 8 12) t) (list (list 27 31) t) (list (list 72 77) nil))))) + (list (list " id $var" 1) (list (list 8 12) 1) (list (list 27 31) 1) (list (list 72 77) 0))))) (phps-mode-test--with-buffer "<?php\n\n$var2 = 4;\n\nfunction myFunction($var)\n{\n $var3 = 3\n if ($var) {\n echo 'Hit';\n }\n if ($var2) {\n echo 'Miss';\n }\n if ($var3) {\n echo 'Hit';\n }\n}\n\nfunction myFunction2($abc)\n{\n if ($var) {\n echo 'Miss';\n }\n if ($abc) {\n echo 'Hit';\n }\n}\n\nif ($var) {\n echo 'Miss';\n}\nif ($var2) {\n echo 'Hit';\n}" "Bookkeeping in function level with variable assignments." (should (equal (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list " id $var2" 1) (list (list 8 13) t) (list " function myFunction id $var" 1) (list (list 40 44) t) (list " function myFunction id $var3" 1) (list (list 52 57) t) (list (list 70 74) t) (list (list 112 117) nil) (list (list 156 161) t) (list " function myFunction2 id $abc" 1) (list (list 215 219) t) (list (list 231 235) nil) (list (list 274 278) t) (list (list 315 319) nil) (list (list 346 351) t))))) + (list (list " id $var2" 1) (list (list 8 13) 1) (list " function myFunction id $var" 1) (list (list 40 44) 1) (list " function myFunction id $var3" 1) (list (list 52 57) 1) (list (list 70 74) 1) (list (list 112 117) 0) (list (list 156 161) 1) (list " function myFunction2 id $abc" 1) (list (list 215 219) 1) (list (list 231 235) 0) (list (list 274 278) 1) (list (list 315 319) 0) (list (list 346 351) 1))))) (phps-mode-test--with-buffer "<?php\n\n// Super-globals\n\nif ($_GET) {\n echo 'Hit';\n}\nif ($_POST) {\n echo 'Hit';\n}\nif ($_COOKIE) {\n echo 'Hit';\n}\nif ($_SESSION) {\n echo 'Hit';\n}\nif ($_REQUEST) {\n echo 'Hit';\n}\nif ($_GLOBALS) {\n echo 'Hit';\n}\nif ($_SERVER) {\n echo 'Hit';\n}\nif ($_FILES) {\n echo 'Hit';\n}\n" "Super-globals" (should (equal (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list (list 30 35) t) (list (list 61 67) t) (list (list 93 101) t) (list (list 127 136) t) (list (list 162 171) t) (list (list 197 206) t) (list (list 232 240) t) (list (list 266 273) t))))) + (list (list (list 30 35) 1) (list (list 61 67) 1) (list (list 93 101) 1) (list (list 127 136) 1) (list (list 162 171) 1) (list (list 197 206) 1) (list (list 232 240) 1) (list (list 266 273) 1))))) (phps-mode-test--with-buffer "<?php\n\nnamespace myNamespaceA {\n $var = 123;\n class myClassA {\n private $var2 = 123;\n function myFunctionA($var3) {\n $var4 = 123;\n if ($var) {\n echo 'Miss';\n }\n if ($var2) {\n echo 'Miss';\n }\n if ($var3) {\n echo 'Hit';\n }\n if ($var4) {\n echo 'Hit';\n }\n }\n\n function myFuncti [...] "Bookkeeping in maximum level with namespaces, classes and functions." (should (equal - (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list " id $var" 1) (list (list 37 41) t) (list " namespace myNamespaceA class myClassA id $var2" 1) (list (list 86 91) t) (list " namespace myNamespaceA class myClassA function myFunctionA id $this" t) (list " namespace myNamespaceA class myClassA function myFunctionA id $var3" 1) (list (list 128 133) t) (list " namespace myNamespaceA class myClassA function myFunctionA id $var4" 1) (list (list 149 154) t) (list (list 178 182) nil) (list (list 245 250) nil) (list (list [...] + (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) 1) + (list (list " id $var" 1) (list (list 37 41) 1) (list " namespace myNamespaceA class myClassA id $var2" 1) (list (list 86 91) 1) (list " namespace myNamespaceA class myClassA function myFunctionA id $this" 1) (list " namespace myNamespaceA class myClassA function myFunctionA id $var3" 1) (list (list 128 133) 1) (list " namespace myNamespaceA class myClassA function myFunctionA id $var4" 1) (list (list 149 154) 1) (list (list 178 182) 0) (list (list 245 250) 0) (list (list 313 [...] (phps-mode-test--with-buffer "<?php\n\n// Conditional assignments\n\n$items = array(1, 2, 3);\nforeach ($items as $item) {\n if ($item) {\n echo 'Hit';\n }\n}\nforeach ($items as $key => $value) {\n if ($key || $value) {\n echo 'Hit';\n }\n}\nfor ($i = 0; $i < count($items); $i++) {\n if ($i) {\n echo 'Hit';\n }\n}\nif ($a = 123) {\n if ($a) {\n echo 'Hit';\n }\n}\nwhile ($b = 123) {\n if ($a) {\n echo 'Hit';\n }\n}\ndo {\n echo 'Hit';\n} while ( [...] "Conditional assignments" (should (equal (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list " id $items" 1) (list (list 36 42) t) (list (list 70 76) t) (list " id $item" 1) (list (list 80 85) t) (list (list 97 102) t) (list (list 143 149) t) (list " id $key" 1) (list (list 153 157) t) (list " id $value" 1) (list (list 161 167) t) (list (list 179 183) t) (list (list 187 193) t) (list " id $i" 1) (list (list 230 232) t) (list (list 238 240) t) (list (list 249 255) t) (list (list 258 260) t) (list (list 274 276) t) (list " id $a" 1) (list (list 312 314) t) [...] + (list (list " id $items" 1) (list (list 36 42) 1) (list (list 70 76) 1) (list " id $item" 1) (list (list 80 85) 1) (list (list 97 102) 1) (list (list 143 149) 1) (list " id $key" 1) (list (list 153 157) 1) (list " id $value" 1) (list (list 161 167) 1) (list (list 179 183) 1) (list (list 187 193) 1) (list " id $i" 1) (list (list 230 232) 1) (list (list 238 240) 1) (list (list 249 255) 1) (list (list 258 260) 1) (list (list 274 276) 1) (list " id $a" 1) (list (list 312 314) 1) [...] (phps-mode-test--with-buffer - "<?php\n\n// Class properties\n\nclass myParent {}\n\nclass myClass extends myParent {\n private $var1 = 123;\n protected static $var2;\n public $var3;\n var $var4;\n function __construct() {\n if ($this) {\n echo 'Hit';\n }\n if ($this->var1) {\n echo 'Hit';\n }\n if (self::$var1) {\n echo 'Miss';\n }\n if (self::$var2) {\n echo 'Hit';\n }\n if ($this->var3) {\n [...] + "<?php\n\n// Class properties\n\nclass myParent {}\n\nclass myClass extends myParent {\n private $var1 = 123;\n protected static $var2;\n public $var3;\n var $var4;\n function __construct() {\n if ($this) {\n echo 'Hit';\n }\n if ($this->var1) {\n echo 'Hit';\n }\n if (self::$var1) {\n echo 'Miss';\n }\n if (self::$var2) {\n echo 'Hit';\n }\n if ($this->var3) {\n [...] "Class properties" ;; (message "Bookkeeping: %s" (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t)) (should (equal (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list " class myParent id $var1" 1) (list (list 93 98) t) (list " class myParent static id $var2" 1) (list (list 127 132) t) (list " class myParent id $var3" 1) (list (list 145 150) t) (list " class myParent id $var4" 1) (list (list 160 165) t) (list " class myParent function __construct id $this" t) (list (list 208 213) t) (list (list 263 268) t) (list (list 270 274) t) (list (list 330 335) nil) (list (list 392 397) t) (list (list 447 452) t) (list (list 454 458) t) (l [...] + (list (list " class myParent id $var1" 1) (list (list 93 98) 1) (list " class myParent static id $var2" 1) (list (list 127 132) 1) (list " class myParent id $var3" 1) (list (list 145 150) 1) (list " class myParent id $var4" 1) (list (list 160 165) 1) (list " class myParent function __construct id $this" 1) (list (list 208 213) 1) (list (list 263 268) 1) (list (list 270 274) 1) (list (list 330 335) 0) (list (list 392 397) 1) (list (list 447 452) 1) (list (list 454 458) 1) (lis [...] (phps-mode-test--with-buffer "<?php\n\ntry {\n \n} catch (\Exception $e) {\n if ($e) {\n echo 'Hit';\n }\n}\n\nif ($e) {\n echo 'Miss';\n}\n" "Try catch variable assignment" (should (equal (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list " id $e" 1) (list (list 38 40) t) (list (list 52 54) t) (list (list 91 93) t))))) + (list (list " id $e" 1) (list (list 38 40) 1) (list (list 52 54) 1) (list (list 91 93) 1))))) (phps-mode-test--with-buffer "<?php\n\n$example = function ($test) {\n if ($test) {\n echo 'Hit';\n }\n if ($example) {\n echo 'Miss';\n }\n};\n$example2 = function ($test2) use ($example) {\n if ($test2) {\n echo 'Hit';\n }\n if ($example) {\n echo 'Hit';\n }\n if ($example2) {\n echo 'Miss';\n }\n if ($example3) {\n echo 'Miss';\n }\n};\nif ($test) {\n echo 'Miss';\n}\nif ($test2) {\n echo 'Miss';\n}" "Anonymous function variable assignments" + ;; (message "Bookkeeping: %s" (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t)) + (should (equal + (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) + (list (list " id $example" 1) (list (list 8 16) 1) (list " anonymous function 1 id $test" 1) (list (list 29 34) 1) (list (list 46 51) 1) (list (list 89 97) 0) (list " id $example2" 1) (list (list 131 140) 1) (list " anonymous function 2 id $test2" 1) (list (list 153 159) 1) (list " anonymous function 2 id $example" 1) (list (list 166 174) 1) (list (list 186 192) 1) (list (list 230 238) 1) (list (list 276 285) 0) (list (list 324 333) 0) (list (list 371 376) 0) (list (list 403 [...] + + (phps-mode-test--with-buffer + "<?php\nclass myClass {\n function random() {}\n function __construct()\n {\n $this->random();\n $this->random['abc'] = 123;\n }\n}" + "Method calls should be avoied in bookkeeping" + ;; (message "Bookkeeping: %s" (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t)) + (should (equal + (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) + (list (list " class myClass function __construct id $this" 1) (list (list 89 94) 1) (list (list 114 119) 1))))) + + (phps-mode-test--with-buffer + "<?php\n$items = array(1, 2, 3);\nforeach ($items as &$item) {\n if ($item) {\n echo 'Hit';\n }\n}\nforeach ($items as $key => &$item2) {\n if ($item) {\n echo 'Hit';\n }\n}" + "Foreach reference variable declaration" + (should (equal + (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) + (list (list " id $items" 1) (list (list 7 13) 1) (list (list 41 47) 1) (list " id $item" 1) (list (list 52 57) 1) (list (list 69 74) 1) (list (list 115 121) 1) (list " id $key" 1) (list (list 125 129) 1) (list " id $item2" 1) (list (list 134 140) 1) (list (list 152 157) 1))))) + + (phps-mode-test--with-buffer + "<?php\n\n[$random, $bandom] = myValues();\nif ($random) {\n echo 'Hit';\n}\nif ($bandom) {\n echo 'Hit';\n}\n\narray($random2, $bandom2] = myValues2();\nif ($random2) {\n echo 'Hit';\n}\nif ($bandom3) {\n echo 'Hit';\n}\n\n " + "Variable declarations in array" (should (equal (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t) - (list (list " id $example" 1) (list (list 8 16) t) (list " anonymous function 1 id $test" 1) (list (list 29 34) t) (list (list 46 51) t) (list (list 89 97) nil) (list " id $example2" 1) (list (list 131 140) t) (list " anonymous function 2 id $test2" 1) (list (list 153 159) t) (list " anonymous function 2 id $example" 1) (list (list 166 174) t) (list (list 186 192) t) (list (list 230 238) t) (list (list 276 285) nil) (list (list 324 333) nil) (list (list 371 376) nil) (list (l [...] + (list (list " id $random" 1) (list (list 9 16) 1) (list " id $bandom" 1) (list (list 18 25) 1) (list (list 45 52) 1) (list (list 78 85) 1) (list " id $random2" 1) (list (list 114 122) 1) (list " id $bandom2" 1) (list (list 124 132) 1) (list (list 153 161) 1) (list (list 187 195) 0))))) )