[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 95f563fc70 102/135: Passing bookkeeping tests
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 95f563fc70 102/135: Passing bookkeeping tests with integrated imenu generation |
Date: |
Sun, 29 Jan 2023 03:11:08 -0500 (EST) |
branch: externals/phps-mode
commit 95f563fc70f3b7d453bfbcf38c1c24ad54c1dc34
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing bookkeeping tests with integrated imenu generation
---
phps-mode-parser-sdt.el | 51 +++++++++++----------------
test/phps-mode-test-ast.el | 88 +++++++++++++++++++++++++++++++---------------
2 files changed, 80 insertions(+), 59 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 4cbecdba29..2e72e4b18a 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -693,7 +693,7 @@
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
- (format "static%s" (nth potential-uri-index
potential-uris)))
+ (format "static %s" (nth potential-uri-index
potential-uris)))
(setq potential-uri-index (1+
potential-uri-index)))))
(setq next-scope-is-self-static-member-operator
t)))))))
@@ -710,7 +710,7 @@
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
- (format "namespace %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (format "namespace %s %s" space-name (nth
potential-uri-index potential-uris)))
(setq potential-uri-index (1+ potential-uri-index)))))
((and
@@ -721,7 +721,7 @@
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
- (format "class %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (format "class %s %s" space-name (nth
potential-uri-index potential-uris)))
(setq potential-uri-index (1+ potential-uri-index)))))
((and
@@ -732,7 +732,7 @@
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
- (format "interface %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (format "interface %s %s" space-name (nth
potential-uri-index potential-uris)))
(setq potential-uri-index (1+ potential-uri-index)))))
((and
@@ -743,7 +743,7 @@
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
- (format "trait %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (format "trait %s %s" space-name (nth
potential-uri-index potential-uris)))
(setq potential-uri-index (1+ potential-uri-index)))))
((and
@@ -757,7 +757,7 @@
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
- (format "function %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (format "function %s %s" space-name (nth
potential-uri-index potential-uris)))
(setq potential-uri-index (1+ potential-uri-index)))))
((equal space-type 'anonymous-function)
@@ -766,7 +766,7 @@
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
- (format "anonymous %s%s" space-name (nth
potential-uri-index potential-uris)))
+ (format "anonymous %s %s" space-name (nth
potential-uri-index potential-uris)))
(setq potential-uri-index (1+ potential-uri-index)))))
((equal space-type 'static)
@@ -775,7 +775,7 @@
(while (< potential-uri-index potential-uri-count)
(setf
(nth potential-uri-index potential-uris)
- (format "static%s" (nth potential-uri-index
potential-uris)))
+ (format "static %s" (nth potential-uri-index
potential-uris)))
(setq potential-uri-index (1+ potential-uri-index)))))
((equal space-type 'arrow-function)
@@ -786,7 +786,7 @@
(new-potential-uris))
(while (< potential-uri-index potential-uri-count)
(push
- (format "arrow %s%s" space-name (nth
potential-uri-index potential-uris))
+ (format "arrow %s %s" space-name (nth
potential-uri-index potential-uris))
new-potential-uris)
(setq potential-uri-index (1+ potential-uri-index)))
(setq potential-uris (append new-potential-uris
potential-uris))
@@ -805,26 +805,17 @@
(while (and
(< potential-uri-index potential-uri-count)
(not matching-uri))
- (let ((old-uri
- (nth potential-uri-index potential-uris))
- (potential-uri))
- (if (string= old-uri "")
- (setq
- potential-uri
- (format
- "id %s"
- name))
- (setq
- potential-uri
- (format
- "%s id %s"
- old-uri
- name)))
- (setf
- (nth potential-uri-index potential-uris)
- potential-uri)
- (when (gethash potential-uri
phps-mode-parser-sdt-symbol-table-by-uri)
- (setq matching-uri potential-uri)))
+ (setq
+ potential-uri
+ (format
+ "%sid %s"
+ (nth potential-uri-index potential-uris)
+ name))
+ (setf
+ (nth potential-uri-index potential-uris)
+ potential-uri)
+ (when (gethash potential-uri
phps-mode-parser-sdt-symbol-table-by-uri)
+ (setq matching-uri potential-uri))
(setq potential-uri-index (1+ potential-uri-index)))
(if matching-uri
matching-uri
@@ -867,7 +858,7 @@
(if (gethash symbol-uri phps-mode-parser-sdt-symbol-table-by-uri)
(progn
(push
- (list symbol-uri symbol-start)
+ `(,symbol-uri . ,symbol-start)
phps-mode-parser-sdt-symbol-imenu)
(puthash
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 7f88b2d070..d08cb31e05 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -135,6 +135,8 @@
"Run test for bookkeeping generation."
(message "-- Running tests for bookkeeping generation... --\n")
+ ;; TODO Should generate imenu for namespaces, classes, interfaces and traits
as well
+
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$var = 'abc';\n\nif ($var2) {\n echo 'This never
happens';\n}\nif ($var) {\n echo 'This happens';\n}"
"Bookkeeping in root level variable assignments #1"
@@ -162,7 +164,7 @@
"<?php\n\nnamespace myNamespaceA {\n $var = 123;\n class myClassA {\n
private $var2 = 123;\n public static 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 fun [...]
"Bookkeeping in maximum level with namespaces, classes and functions."
'(((37 41) 1) ((485 490) 2) ((881 886) 4) ((814 819) 2) ((746 751) 0) ((678
683) 0) ((610 615) 0) ((543 547) 0) ((514 519) 4) ((142 147) 5) ((394 399) 6)
((327 332) 5) ((259 264) 0) ((192 196) 0) ((163 168) 6) ((86 91) 7) ((957 961)
1) ((999 1004) 0) ((1043 1048) 0) ((1087 1092) 0) ((1131 1136) 0) ((1175 1180)
0) ((1243 1248) 8) ((2088 2094) 9) ((2894 2900) 9) ((2826 2832) 11) ((2757
2763) 0) ((2689 2694) 0) ((2621 2626) 0) ((2553 2558) 0) ((2486 2491) 0) ((2419
2424) 0) ((2351 2356) [...]
- '(("namespace myNamespaceA id $var" . 37) ("namespace myNamespaceAclass
myClassAfunction myFunctionB id $var5" . 485) ("namespace myNamespaceAclass
myClassAfunction myFunctionB id $this" . 500) ("namespace myNamespaceAclass
myClassAfunction myFunctionB id $var6" . 514) ("namespace myNamespaceAclass
myClassAfunction myFunctionA id $var3" . 142) ("namespace myNamespaceAclass
myClassAfunction myFunctionA id $var4" . 163) ("namespace myNamespaceAclass
myClassA id $var2" . 86) ("namespace [...]
+ '(("namespace myNamespaceA id $var" . 37) ("namespace myNamespaceA class
myClassA function myFunctionB id $var5" . 485) ("namespace myNamespaceA class
myClassA function myFunctionB id $this" . 500) ("namespace myNamespaceA class
myClassA function myFunctionB id $var6" . 514) ("namespace myNamespaceA class
myClassA function myFunctionA id $var3" . 142) ("namespace myNamespaceA class
myClassA function myFunctionA id $var4" . 163) ("namespace myNamespaceA class
myClassA id $var2" . 86) ( [...]
(phps-mode-test-ast--should-bookkeep
"<?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 ( [...]
@@ -173,42 +175,50 @@
(phps-mode-test-ast--should-bookkeep
"<?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
(static::$var2) {\n [...]
"Bookkeeping of class properties"
- '((" class myClass function __construct id $this" ((194 743))) (" class
myClass id $var4" ((160 165))) (" class myClass id $var3" ((145 150))) (" class
myClass static id $var2" ((127 132))) (" class myClass id $var1" ((93 98)))
((639 643) 0) ((632 637) 1) ((578 582) 1) ((571 576) 1) ((517 521) 1) ((510
515) 1) ((455 460) 1) ((392 397) 1) ((330 335) 0) ((270 274) 1) ((263 268) 1)
((208 213) 1) ((160 165) 1) ((145 150) 1) ((127 132) 1) ((93 98) 1) ((751 756)
0)))
+ '(((639 643) 0) ((632 637) 1) ((578 582) 2) ((571 576) 1) ((517 521) 3)
((510 515) 1) ((455 460) 4) ((392 397) 4) ((330 335) 0) ((270 274) 5) ((263
268) 1) ((208 213) 1) ((160 165) 2) ((145 150) 3) ((127 132) 4) ((93 98) 5)
((751 756) 0))
+ '(("class myClass function __construct id $this" . 194) ("class myClass id
$var4" . 160) ("class myClass id $var3" . 145) ("class myClass static id $var2"
. 127) ("class myClass id $var1" . 93)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\ntry {\n \n} catch (\\Exception $e) {\n if ($e) {\n
echo 'Hit';\n }\n}\n\nif ($e) {\n echo 'Miss';\n}\n"
"Bookkeeping of try catch variable assignment"
- '((" id $e" ((39 41))) ((39 41) 1) ((53 55) 1) ((92 94) 1)))
+ '(((39 41) 1) ((53 55) 1) ((92 94) 1))
+ '(("id $e" . 39)))
(phps-mode-test-ast--should-bookkeep
"<?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};\n$example3 = function ($test3) use ($example4) {\n if ($test3) {\n
echo 'Hit';\n }\n [...]
"Bookkeeping of anonymous function variable assignments and lexical vars"
- '((" id $example" ((8 16))) (" anonymous 1 id $test" ((29 34))) ((29 34) 1)
((89 97) 0) ((46 51) 1) ((8 16) 1) (" id $example2" ((131 140))) (" anonymous 2
id $example" ((166 174))) (" anonymous 2 id $test2" ((153 159))) ((166 174) 1)
((153 159) 1) ((324 333) 0) ((276 285) 0) ((230 238) 1) ((186 192) 1) ((131
140) 1) (" id $example3" ((367 376))) (" anonymous 3 id $example4" ((402 411)))
(" anonymous 3 id $test3" ((389 395))) ((402 411) 0) ((389 395) 1) ((467 476)
1) ((423 429) 1) ((3 [...]
+ '(((29 34) 2) ((89 97) 0) ((46 51) 2) ((8 16) 1) ((166 174) 1) ((153 159)
5) ((324 333) 0) ((276 285) 0) ((230 238) 4) ((186 192) 5) ((131 140) 3) ((402
411) 0) ((389 395) 8) ((467 476) 7) ((423 429) 8) ((367 376) 6) ((513 518) 0)
((545 551) 0))
+ '(("id $example" . 8) ("anonymous 1 id $test" . 29) ("id $example2" . 131)
("anonymous 2 id $example" . 166) ("anonymous 2 id $test2" . 153) ("id
$example3" . 367) ("anonymous 3 id $example4" . 402) ("anonymous 3 id $test3" .
389)))
(phps-mode-test-ast--should-bookkeep
"<?php\nclass myClass {\n function random() {}\n function
__construct()\n {\n $this->random();\n $this->random['abc'] =
123;\n }\n}"
"Method calls should be avoided in bookkeeping"
- '((" class myClass function __construct id $this" ((79 147))) ((121 127) 0)
((114 119) 1) ((89 94) 1)))
+ '(((121 127) 0) ((114 119) 1) ((89 94) 1))
+ '(("class myClass function __construct id $this" . 79)))
(phps-mode-test-ast--should-bookkeep
"<?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}"
"Bookkeeping of foreach reference variable declaration"
- '((" id $items" ((7 13))) ((7 13) 1) (" id $item" ((52 57))) ((69 74) 1)
((52 57) 1) ((41 47) 1) (" id $item2" ((134 140))) (" id $key" ((125 129)))
((152 157) 1) ((134 140) 1) ((125 129) 1) ((115 121) 1)))
+ '(((7 13) 1) ((69 74) 2) ((52 57) 2) ((41 47) 1) ((152 157) 2) ((134 140)
3) ((125 129) 4) ((115 121) 1))
+ '(("id $items" . 7) ("id $item" . 52) ("id $item2" . 134) ("id $key" .
125)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n[$random, $bandom] = myValues();\nif ($random) {\n echo
'Hit';\n}\nif ($bandom) {\n echo 'Hit';\n}\n"
"Bookkeeping of variable declarations in array"
- '((" id $bandom" ((18 25))) (" id $random" ((9 16))) ((18 25) 1) ((9 16) 1)
((45 52) 1) ((78 85) 1)))
+ '(((18 25) 1) ((9 16) 2) ((45 52) 2) ((78 85) 1))
+ '(("id $bandom" . 18) ("id $random" . 9)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$var = 123;\n\nfunction test($abc) {\n global $var, $var2;\n
if ($var) {\n echo 'Hit';\n }\n if ($var2) {\n echo
'Hit';\n }\n}"
"Bookkeeping of global variable declaration in function"
- '((" id $var" ((8 12))) ((8 12) 1) (" function test id $abc" ((35 39))) ("
function test id $var2" ((60 65))) (" function test id $var" ((54 58))) ((35
39) 1) ((117 122) 1) ((75 79) 1) ((60 65) 0) ((54 58) 1)))
+ '(((8 12) 1) ((35 39) 2) ((117 122) 3) ((75 79) 4) ((60 65) 0) ((54 58) 1))
+ '(("id $var" . 8) ("function test id $abc" . 35) ("function test id $var2"
. 60) ("function test id $var" . 54)))
(phps-mode-test-ast--should-bookkeep
"<?php\n$y = 1;\n$fn1 = fn($x) => $x + $y;\n$z = 1;\n$fn = fn($x2) =>
fn($y2) => $x2 * $y2 + $z;\nfn(array $x3) => $x3;\n$x4 = 4;\nstatic fn(): int
=> $x4;\nfn($x5 = 42) => $x5;\nfn(&$x6) => $x6;\nfn&($x7) => $x7;\nfn($x8,
...$rest) => $rest;"
"Bookkeeping in arrow functions"
- '((" id $y" ((7 9))) ((7 9) 1) (" id $fn1" ((15 19))) (" arrow 1 id $x"
((25 27))) ((25 27) 1) ((37 39) 1) ((32 34) 1) ((15 19) 1) (" id $z" ((41 43)))
((41 43) 1) (" id $fn" ((49 52))) (" arrow 3 id $x2" ((58 61))) (" arrow 2 id
$y2" ((69 72))) ((58 61) 1) ((69 72) 1) ((89 91) 1) ((83 86) 1) ((77 80) 1)
((49 52) 1) (" arrow 4 id $x3" ((102 105))) ((102 105) 1) ((110 113) 1) (" id
$x4" ((115 118))) ((115 118) 1) ((144 147) 1) (" arrow 6 id $x5" ((152 155)))
((152 155) 1) ((165 168) 1) [...]
+ '(((7 9) 1) ((25 27) 3) ((37 39) 1) ((32 34) 3) ((15 19) 2) ((41 43) 4)
((58 61) 6) ((69 72) 7) ((89 91) 4) ((83 86) 7) ((77 80) 6) ((49 52) 5) ((102
105) 8) ((110 113) 8) ((115 118) 9) ((144 147) 9) ((152 155) 10) ((165 168) 10)
((174 177) 11) ((182 185) 11) ((191 194) 12) ((199 202) 12) ((215 220) 13)
((207 210) 14) ((225 230) 13))
+ '(("id $y" . 7) ("id $fn1" . 15) ("arrow 1 id $x" . 25) ("id $z" . 41) ("id
$fn" . 49) ("arrow 3 id $x2" . 58) ("arrow 2 id $y2" . 69) ("arrow 4 id $x3" .
102) ("id $x4" . 115) ("arrow 6 id $x5" . 152) ("arrow 7 id $x6" . 174) ("arrow
8 id $x7" . 191) ("arrow 9 id $rest" . 215) ("arrow 9 id $x8" . 207)))
;; (phps-mode-test-ast--should-bookkeep
;; "<?php\n$z = (object) array('name' => 'random');\nif ($z->name) {\n
echo 'Hit';\n}"
@@ -218,102 +228,122 @@
(phps-mode-test-ast--should-bookkeep
"<?php\nif (!$var = false) {\n echo 'Hit';\n}\n"
"Bookkeeping negative conditional assignment"
- '((" id $var" ((12 16))) ((12 16) 1)))
+ '(((12 16) 1))
+ '(("id $var" . 12)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\nif (isset($x)) {\n if ($x) {\n echo 'Hit';\n if
(isset($i, $u)) {\n if ($i) {\n echo 'Hit';\n
}\n if ($u) {\n echo 'Hit';\n }\n
if ($x) {\n echo 'Hit';\n }\n }\n
if ($i) {\n echo 'Miss';\n }\n if ($u) {\n
echo 'Miss';\n }\n }\n}\nif ($x) {\n echo 'Miss';\n}\n\nif
(!empty($y)) {\n if ( [...]
"Bookkeeping of isset() and !empty() scoped variables"
- '((" id $i" ((77 79))) (" id $u" ((81 83))) (" id $x" ((18 20))) ((355 357)
1) ((302 304) 1) ((232 234) 1) ((168 170) 1) ((104 106) 1) ((81 83) 1) ((77 79)
1) ((33 35) 1) ((18 20) 1) ((408 410) 1) (" id $L" ((519 521))) (" id $k" ((505
507))) (" id $y" ((445 447))) ((793 795) 1) ((740 742) 1) ((670 672) 1) ((606
608) 1) ((542 544) 1) ((519 521) 1) ((505 507) 1) ((460 462) 1) ((445 447) 1)
((846 848) 1)))
+ '(((355 357) 2) ((302 304) 1) ((232 234) 3) ((168 170) 2) ((104 106) 1)
((81 83) 2) ((77 79) 1) ((33 35) 3) ((18 20) 3) ((408 410) 3) ((793 795) 4)
((740 742) 5) ((670 672) 6) ((606 608) 4) ((542 544) 5) ((519 521) 4) ((505
507) 5) ((460 462) 6) ((445 447) 6) ((846 848) 6))
+ '(("id $i" . 77) ("id $u" . 81) ("id $x" . 18) ("id $L" . 519) ("id $k" .
505) ("id $y" . 445)))
(phps-mode-test-ast--should-bookkeep
"<?php\ninterface myInterface\n{\n function myFunction1();\n function
myFunction2($x);\n}\n"
"Bookkeeping variable in interface function"
- '((" interface myInterface function myFunction2 id $x" ((84 86))) ((84 86)
1)))
+ '(((84 86) 1))
+ '(("interface myInterface function myFunction2 id $x" . 84)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\nfunction myFunction1()\n{\n return isset($a);\n}\n\nfunction
myFunction2()\n{\n $b = 2;\n if ($b) {\n echo 'Hit';\n }\n
if ($a) {\n echo 'Miss';\n }\n}\n"
"Bookkeeping after definition condition"
- '((" function myFunction1 id $a" ((50 52))) ((50 52) 1) (" function
myFunction2 id $b" ((87 89))) ((143 145) 0) ((103 105) 1) ((87 89) 1)))
+ '(((50 52) 1) ((143 145) 0) ((103 105) 2) ((87 89) 2))
+ '(("function myFunction1 id $a" . 50) ("function myFunction2 id $b" . 87)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$a = array(1, 2, 3);\nforeach ($a as $uri => $page)\n{\n if
(isset($pages)) {\n if ($a) {\n echo 'Hit';\n }\n
if ($uri) {\n echo 'Hit';\n }\n if ($page) {\n
echo 'Hit';\n }\n }\n}\n"
"Bookkeeping of foreach variable inside if (isset()) block"
- '((" id $a" ((8 10))) ((8 10) 1) (" id $pages" ((75 81))) (" id $page" ((52
57))) (" id $uri" ((44 48))) ((204 209) 1) ((150 154) 1) ((98 100) 1) ((75 81)
1) ((52 57) 1) ((44 48) 1) ((38 40) 1)))
+ '(((8 10) 1) ((204 209) 3) ((150 154) 4) ((98 100) 1) ((75 81) 2) ((52 57)
3) ((44 48) 4) ((38 40) 1))
+ '(("id $a" . 8) ("id $pages" . 75) ("id $page" . 52) ("id $uri" . 44)))
(phps-mode-test-ast--should-bookkeep
"<?php\nif (isset($b)) {\n $b = false;\n}\n$c = 2;\n\nif ($c) {\n
echo 'Hit';\n}\n"
"Bookkeeping of variable after isset() block"
- '((" id $b" ((28 30) (17 19))) ((28 30) 1) ((17 19) 1) (" id $c" ((42 44)))
((42 44) 1) ((55 57) 1)))
+ '(((28 30) 1) ((17 19) 0) ((42 44) 3) ((55 57) 3))
+ '(("id $b" . 28) ("id $b" . 17)("id $c" . 42)))
(phps-mode-test-ast--should-bookkeep
"<?php\nif (!isset($a)) {\n if ($a) {\n echo 'Miss';\n }\n}"
"Bookkeeping for variable in negative isset() conditional"
- '((" id $a" ((18 20))) ((33 35) 1) ((18 20) 1)))
+ '(((33 35) 1) ((18 20) 1))
+ '(("id $a" . 18)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\nfunction myFunction($a, $b, $c, $d)\n{\n global $f, $g;\n
if (isset($f)) {\n if (!empty($g)) {\n if ($a) {\n
echo 'Hit';\n }\n if ($b) {\n echo
'Hit';\n }\n if ($c) {\n echo 'Hit';\n
}\n if ($d) {\n echo 'Hit';\n }\n
}\n }\n}\n"
"Bookkeeping variables inside nested isset() !empty() blocks"
- '((" function myFunction id $d" ((40 42))) (" function myFunction id $c"
((36 38))) (" function myFunction id $b" ((32 34))) (" function myFunction id
$a" ((28 30))) (" function myFunction id $g" ((105 107) (61 63))) (" function
myFunction id $f" ((79 81) (57 59))) ((40 42) 1) ((36 38) 1) ((32 34) 1) ((28
30) 1) ((320 322) 1) ((256 258) 1) ((192 194) 1) ((128 130) 1) ((105 107) 1)
((79 81) 1) ((61 63) 0) ((57 59) 0)))
+ '(((40 42) 1) ((36 38) 2) ((32 34) 3) ((28 30) 4) ((320 322) 1) ((256 258)
2) ((192 194) 3) ((128 130) 4) ((105 107) 5) ((79 81) 6) ((61 63) 0) ((57 59)
0))
+ '(("function myFunction id $d" . 40) ("function myFunction id $c" . 36)
("function myFunction id $b" . 32) ("function myFunction id $a" . 28)
("function myFunction id $g" . 105) ("function myFunction id $f" . 79)
("function myFunction id $g" . 61) ("function myFunction id $f" . 57)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$var = 123;\n\nfunction test($abc) {\n static $var;\n if
($var) {\n echo 'Hit';\n }\n}"
"Bookkeeping of static variable declaration in function"
- '((" id $var" ((8 12))) ((8 12) 1) (" function test id $abc" ((35 39))) ("
function test id $var" ((54 58))) ((35 39) 1) ((68 72) 1) ((54 58) 1)))
+ '(((8 12) 1) ((35 39) 2) ((68 72) 3) ((54 58) 3))
+ '(("id $var" . 8) ("function test id $abc" . 35) ("function test id $var" .
54)))
(phps-mode-test-ast--should-bookkeep
"<?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"
- '((" id $b" ((19 21))) (" id $a" ((15 17))) ((19 21) 1) ((15 17) 1) ((28
30) 1) (" function myFunction id $c" ((73 75))) (" function myFunction id $a"
((90 92))) ((73 75) 1) ((142 144) 0) ((102 104) 1) ((90 92) 1)))
+ '(((19 21) 1) ((15 17) 2) ((28 30) 2) ((73 75) 3) ((142 144) 0) ((102 104)
4) ((90 92) 2))
+ '(("id $b" . 19) ("id $a" . 15) ("function myFunction id $c" . 73)
("function myFunction id $a" . 90)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\nstatic $a;\n\nif ($a) {}\n\nfunction test()\n{\n static $a;\n
if ($a) {}\n}\n\nclass There\n{\n function here()\n {\n static
$a;\n if ($a) {}\n }\n}"
"Bookkeeping of static variables in different scopes without namespaces"
- '((" id $a" ((15 17))) ((15 17) 1) ((24 26) 1) (" function test id $a" ((61
63))) ((73 75) 1) ((61 63) 1) (" class There function here id $this" ((121
166))) (" class There function here id $a" ((138 140))) ((154 156) 1) ((138
140) 1)))
+ '(((15 17) 1) ((24 26) 1) ((73 75) 2) ((61 63) 2) ((154 156) 4) ((138 140)
4))
+ '(("id $a" . 15) ("function test id $a" . 61) ("class There function here
id $this" . 121) ("class There function here id $a" . 138)))
(phps-mode-test-ast--should-bookkeep
"<?php\nclass There\n{\n private $variable;\n private \\My\\Random
$variable2;\n private string $variable3;\n private static $variable4;\n
private static \\My\\Random $variable5;\n private static string
$variable6;\n function here()\n {\n if ($this->variable) {}\n
if ($this->variable2) {}\n if ($this->variable3) {}\n if
($this->variable4) {}\n if (self::$variable4) {}\n if
(self::$variable5) {}\n if (self::$varia [...]
"Bookkeeping of typed class variables"
- '((" class There function here id $this" ((245 482))) (" class There static
id $variable6" ((209 219))) (" class There static id $variable5" ((171 181)))
(" class There static id $variable4" ((129 139))) (" class There id $variable3"
((98 108))) (" class There id $variable2" ((67 77))) (" class There id
$variable" ((33 42))) ((462 472) 1) ((429 439) 1) ((396 406) 1) ((364 373) 0)
((357 362) 1) ((331 340) 1) ((324 329) 1) ((298 307) 1) ((291 296) 1) ((266
274) 1) ((259 264) 1) ((209 21 [...]
+ '(((462 472) 2) ((429 439) 3) ((396 406) 4) ((364 373) 0) ((357 362) 1)
((331 340) 5) ((324 329) 1) ((298 307) 6) ((291 296) 1) ((266 274) 7) ((259
264) 1) ((209 219) 2) ((171 181) 3) ((129 139) 4) ((98 108) 5) ((67 77) 6) ((33
42) 7))
+ '(("class There function here id $this" . 245) ("class There static id
$variable6" . 209) ("class There static id $variable5" . 171) ("class There
static id $variable4" . 129) ("class There id $variable3" . 98) ("class There
id $variable2" . 67) ("class There id $variable" . 33)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n$a = $b = $c = 3;\n\nif ($a) {\n echo 'a=',$a;\n} else {\n
echo '$a is undefined!';\n}\nif ($b) {\n echo 'b=',$b;\n} else {\n echo
'$b is undefined!';\n}\nif ($c) {\n echo 'c=',$c;\n} else {\n echo '$c is
undefined!';\n}"
"Bookkeeping of chained variable assignments"
- '((" id $a" ((8 10))) (" id $b" ((13 15))) (" id $c" ((18 20))) ((18 20) 1)
((13 15) 1) ((8 10) 1) ((51 53) 1) ((31 33) 1) ((119 121) 1) ((99 101) 1) ((187
189) 1) ((167 169) 1)))
+ '(((18 20) 3) ((13 15) 2) ((8 10) 1) ((51 53) 1) ((31 33) 1) ((119 121) 2)
((99 101) 2) ((187 189) 3) ((167 169) 3))
+ '(("id $a" . 8) ("id $b" . 13) ("id $c" . 18)))
(phps-mode-test-ast--should-bookkeep
"<?php\nclass There\n{\n private $variable;\n private ?\\My\\Random
$variable2;\n private string $variable3;\n private static $variable4;\n
private static \\My\\Random $variable5;\n private static ?string
$variable6;\n function here()\n {\n if ($this->variable) {}\n
if ($this->variable2) {}\n if ($this->variable3) {}\n if
($this->variable4) {}\n if (self::$variable4) {}\n if
(self::$variable5) {}\n if (self::$var [...]
"Bookkeeping of nullable typed class variables"
- '((" class There function here id $this" ((247 484))) (" class There static
id $variable6" ((211 221))) (" class There static id $variable5" ((172 182)))
(" class There static id $variable4" ((130 140))) (" class There id $variable3"
((99 109))) (" class There id $variable2" ((68 78))) (" class There id
$variable" ((33 42))) ((464 474) 1) ((431 441) 1) ((398 408) 1) ((366 375) 0)
((359 364) 1) ((333 342) 1) ((326 331) 1) ((300 309) 1) ((293 298) 1) ((268
276) 1) ((261 266) 1) ((211 22 [...]
+ '(((464 474) 2) ((431 441) 3) ((398 408) 4) ((366 375) 0) ((359 364) 1)
((333 342) 5) ((326 331) 1) ((300 309) 6) ((293 298) 1) ((268 276) 7) ((261
266) 1) ((211 221) 2) ((172 182) 3) ((130 140) 4) ((99 109) 5) ((68 78) 6) ((33
42) 7))
+ '(("class There function here id $this" . 247) ("class There static id
$variable6" . 211) ("class There static id $variable5" . 172) ("class There
static id $variable4" . 130) ("class There id $variable3" . 99) ("class There
id $variable2" . 68) ("class There id $variable" . 33)))
(phps-mode-test-ast--should-bookkeep
"<?php\nclass MyClass\n{\n static function here()\n {\n if
($this) {\n // Miss;\n }\n }\n function there()\n
{\n if ($this) {\n // Hit\n }\n }\n}\n"
"Bookkeeping of $this not available inside static method"
- '((" class MyClass function there id $this" ((139 196))) ((153 158) 1) ((68
73) 0)))
+ '(((153 158) 1) ((68 73) 0))
+ '(("class MyClass function there id $this" . 139)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\nclass myClass\n{\n private $tost = 'abc';\n public function
test($d)\n {\n return fn($e) => $this->tost . $d . $e;\n
}\n}\n\n$a = new myClass();\necho $a->test('def')('ghi');"
"Bookkeeping of $this reference inside arrow function inside of method"
- '((" class myClass function test id $d" ((76 78))) (" class myClass
function test id $this" ((84 139))) (" class myClass arrow 1 function test id
$e" ((104 106))) (" class myClass id $tost" ((36 41))) ((76 78) 1) ((104 106)
1) ((130 132) 1) ((125 127) 1) ((118 122) 1) ((111 116) 1) ((36 41) 1) (" id
$a" ((143 145))) ((143 145) 1) ((168 170) 1)))
+ '(((76 78) 1) ((104 106) 3) ((130 132) 3) ((125 127) 1) ((118 122) 4) ((111
116) 2) ((36 41) 4) ((143 145) 5) ((168 170) 5))
+ '(("class myClass function test id $d" . 76) ("class myClass function test
id $this" . 84) ("class myClass arrow 1 function test id $e" . 104) ("class
myClass id $tost" . 36) ("id $a" . 143)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\nclass myClass\n{\n static $var = '123';\n static function
myMethod($a)\n {\n return fn($b) => self::$var . $a . $b;\n
}\n}\n\necho myClass::myMethod('4')('5');"
"Bookkeeping of self reference inside arrow function inside of static
method"
- '((" class myClass function myMethod id $a" ((78 80))) (" class myClass
arrow 1 function myMethod id $b" ((106 108))) (" class myClass static id $var"
((35 39))) ((78 80) 1) ((106 108) 1) ((131 133) 1) ((126 128) 1) ((119 123) 1)
((35 39) 1)))
+ '(((78 80) 1) ((106 108) 2) ((131 133) 2) ((126 128) 1) ((119 123) 3) ((35
39) 3))
+ '(("class myClass function myMethod id $a" . 78) ("class myClass arrow 1
function myMethod id $b" . 106) ("class myClass static id $var" . 35)))
(phps-mode-test-ast--should-bookkeep
"<?php\nnamespace myNamespace;\nclass myClass\n{\n private $property1 =
'';\n private $property2;\n protected function myMethod(\n
$argument1,\n $argument2,\n $argument3\n ) {\n if
($this->property2) {\n echo 'was here';\n }\n /*
@codingStandardsIgnoreEnd */\n if (\n $argument1\n
&& $argument2\n && $argument3\n && $argument4\n
&& !empty($argument1['index'])\n [...]
"Bookkeeping of properties inside if condition list"
- '((" namespace myNamespace class myClass function myMethod id $argument3"
((180 190))) (" namespace myNamespace class myClass function myMethod id
$argument2" ((160 170))) (" namespace myNamespace class myClass function
myMethod id $argument1" ((140 150) (446 456))) (" namespace myNamespace class
myClass function myMethod id $this" ((197 581))) (" namespace myNamespace class
myClass id $property2" ((87 97))) (" namespace myNamespace class myClass id
$property1" ((58 68))) ((180 190) 1 [...]
+ '(((180 190) 1) ((160 170) 2) ((140 150) 3) ((544 553) 7) ((537 542) 4)
((514 524) 3) ((489 498) 7) ((482 487) 4) ((446 456) 3) ((413 423) 0) ((387
397) 1) ((361 371) 2) ((335 345) 3) ((218 227) 6) ((211 216) 4) ((87 97) 6)
((58 68) 7))
+ '(("namespace myNamespace class myClass function myMethod id $argument3" .
180) ("namespace myNamespace class myClass function myMethod id $argument2" .
160) ("namespace myNamespace class myClass function myMethod id $argument1" .
140) ("namespace myNamespace class myClass function myMethod id $this" . 197)
("namespace myNamespace class myClass function myMethod id $argument1" . 446)
("namespace myNamespace class myClass id $property2" . 87) ("namespace
myNamespace class myClass id $pr [...]
(phps-mode-test-ast--should-bookkeep
"<?php\ntrait MyTrait {\n private $var = 'abc';\n public function
sayHello() {\n if ($this->var) {\n echo 'Hit';\n }\n
}\n}\n"
"A basic trait class"
- '((" trait MyTrait function sayHello id $this" ((80 147))) (" trait MyTrait
id $var" ((35 39))) ((101 104) 1) ((94 99) 1) ((35 39) 1)))
+ '(((101 104) 2) ((94 99) 1) ((35 39) 2))
+ '(("trait MyTrait function sayHello id $this" . 80) ("trait MyTrait id
$var" . 35)))
(phps-mode-test-ast--should-bookkeep
"<?php\nclass Person {\n public function __construct(\n private
string $name,\n private int $age,\n public $address\n ) {}\n}"
"Class with class properties in constructor."
- '((" class Person function __construct id $address" ((126 134))) (" class
Person id $address" ((126 134))) (" class Person function __construct id $age"
((105 109))) (" class Person id $age" ((105 109))) (" class Person function
__construct id $name" ((78 83))) (" class Person id $name" ((78 83))) ((126
134) 1) ((105 109) 1) ((78 83) 1)))
+ '(((126 134) 1) ((105 109) 3) ((78 83) 5))
+ '(("class Person function __construct id $address" . 126) ("class Person id
$address" . 126) ("class Person function __construct id $age" . 105) ("class
Person id $age" . 105) ("class Person function __construct id $name" . 78)
("class Person id $name" . 78)))
(message "\n-- Ran tests for bookkeeping generation. --"))
- [elpa] externals/phps-mode e2f2c86e18 059/135: Improved class properties bookkeeping test, (continued)
- [elpa] externals/phps-mode e2f2c86e18 059/135: Improved class properties bookkeeping test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode eac10d63e6 063/135: Started on bookkeeping of variables inside anonymous functions, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e924ac83b6 065/135: Improved bookkeeping test for anonymous function, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e614a20ada 066/135: Added bookkeeping for referenced foreach variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d33625bb1a 067/135: Bookkeeping for array assignment passing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode a646676781 084/135: Passing more bookkeeping tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7609f09f04 090/135: More bookkeeping final touches, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test for trait class symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ada5e79291 097/135: Passing bookkeeping test for class properties in class constructor, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 8aae220c57 098/135: Started on integrating imenu generation in SDT bookkeeping, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 95f563fc70 102/135: Passing bookkeeping tests with integrated imenu generation,
Christian Johansson <=
- [elpa] externals/phps-mode ae516f9e19 105/135: Using separate imenu items for redeclared symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode b21c9f3f3a 107/135: Imenu generation via SDT all tests now passing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 3332b2bfa9 109/135: Fixes syntax coloring of super-globals, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode bddf800099 111/135: Added failing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d98f6d78d8 114/135: Saving symbol-table after parse, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1594c15e9e 117/135: More work on imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 776c818ff9 121/135: Passing some more imenu tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode c6e4844753 122/135: Some byte-compilation fixes, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 96eeff74f8 130/135: Added more todo items for bookkeeping and imenu, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 66ad034207 025/135: SDT member_modifier, Christian Johansson, 2023/01/29