emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode b21c9f3f3a 107/135: Imenu generation via SDT


From: Christian Johansson
Subject: [elpa] externals/phps-mode b21c9f3f3a 107/135: Imenu generation via SDT all tests now passing
Date: Sun, 29 Jan 2023 03:11:09 -0500 (EST)

branch: externals/phps-mode
commit b21c9f3f3abc13db25f57c34eb4e4ec16eef138e
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Imenu generation via SDT all tests now passing
---
 phps-mode-parser-sdt.el    | 68 ++++++++++++++++++++++++++++++++++++++---
 test/phps-mode-test-ast.el | 76 +++++++++++++++++++++++-----------------------
 2 files changed, 102 insertions(+), 42 deletions(-)

diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 0070657163..1170a74429 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -839,6 +839,10 @@
                 scope-start
                 scope-end)
                phps-mode-parser-sdt-symbol-table)
+              (puthash
+               scope-uri
+               (list phps-mode-parser-sdt-symbol-table-index)
+               phps-mode-parser-sdt-symbol-table-by-uri)
               (push
                `(,scope-uri . ,scope-start)
                phps-mode-parser-sdt-symbol-imenu))))
@@ -864,6 +868,10 @@
                     scope-start
                     scope-end)
                    phps-mode-parser-sdt-symbol-table)
+                  (puthash
+                   scope-uri
+                   (list phps-mode-parser-sdt-symbol-table-index)
+                   phps-mode-parser-sdt-symbol-table-by-uri)
                   (push
                    `(,scope-uri . ,scope-start)
                    phps-mode-parser-sdt-symbol-imenu)))
@@ -884,6 +892,10 @@
                   scope-start
                   scope-end)
                  phps-mode-parser-sdt-symbol-table)
+                (puthash
+                 scope-uri
+                 (list phps-mode-parser-sdt-symbol-table-index)
+                 phps-mode-parser-sdt-symbol-table-by-uri)
                 (push
                  `(,scope-uri . ,scope-start)
                  phps-mode-parser-sdt-symbol-imenu)))))
@@ -909,6 +921,10 @@
                     scope-start
                     scope-end)
                    phps-mode-parser-sdt-symbol-table)
+                  (puthash
+                   scope-uri
+                   (list phps-mode-parser-sdt-symbol-table-index)
+                   phps-mode-parser-sdt-symbol-table-by-uri)
                   (push
                    `(,scope-uri . ,scope-start)
                    phps-mode-parser-sdt-symbol-imenu)))
@@ -929,6 +945,10 @@
                   scope-start
                   scope-end)
                  phps-mode-parser-sdt-symbol-table)
+                (puthash
+                 scope-uri
+                 (list phps-mode-parser-sdt-symbol-table-index)
+                 phps-mode-parser-sdt-symbol-table-by-uri)
                 (push
                  `(,scope-uri . ,scope-start)
                  phps-mode-parser-sdt-symbol-imenu)))))
@@ -954,6 +974,10 @@
                     scope-start
                     scope-end)
                    phps-mode-parser-sdt-symbol-table)
+                  (puthash
+                   scope-uri
+                   (list phps-mode-parser-sdt-symbol-table-index)
+                   phps-mode-parser-sdt-symbol-table-by-uri)
                   (push
                    `(,scope-uri . ,scope-start)
                    phps-mode-parser-sdt-symbol-imenu)))
@@ -974,6 +998,10 @@
                   scope-start
                   scope-end)
                  phps-mode-parser-sdt-symbol-table)
+                (puthash
+                 scope-uri
+                 (list phps-mode-parser-sdt-symbol-table-index)
+                 phps-mode-parser-sdt-symbol-table-by-uri)
                 (push
                  `(,scope-uri . ,scope-start)
                  phps-mode-parser-sdt-symbol-imenu)))))
@@ -1002,6 +1030,10 @@
                       scope-start
                       scope-end)
                      phps-mode-parser-sdt-symbol-table)
+                    (puthash
+                     scope-uri
+                     (list phps-mode-parser-sdt-symbol-table-index)
+                     phps-mode-parser-sdt-symbol-table-by-uri)
                     (push
                      `(,scope-uri . ,scope-start)
                      phps-mode-parser-sdt-symbol-imenu))))
@@ -1025,6 +1057,10 @@
                       scope-start
                       scope-end)
                      phps-mode-parser-sdt-symbol-table)
+                    (puthash
+                     scope-uri
+                     (list phps-mode-parser-sdt-symbol-table-index)
+                     phps-mode-parser-sdt-symbol-table-by-uri)
                     (push
                      `(,scope-uri . ,scope-start)
                      phps-mode-parser-sdt-symbol-imenu))))
@@ -1048,6 +1084,10 @@
                       scope-start
                       scope-end)
                      phps-mode-parser-sdt-symbol-table)
+                    (puthash
+                     scope-uri
+                     (list phps-mode-parser-sdt-symbol-table-index)
+                     phps-mode-parser-sdt-symbol-table-by-uri)
                     (push
                      `(,scope-uri . ,scope-start)
                      phps-mode-parser-sdt-symbol-imenu)))
@@ -1071,6 +1111,10 @@
                       scope-start
                       scope-end)
                      phps-mode-parser-sdt-symbol-table)
+                    (puthash
+                     scope-uri
+                     (list phps-mode-parser-sdt-symbol-table-index)
+                     phps-mode-parser-sdt-symbol-table-by-uri)
                     (push
                      `(,scope-uri . ,scope-start)
                      phps-mode-parser-sdt-symbol-imenu)))))
@@ -1094,13 +1138,17 @@
                     scope-start
                     scope-end)
                    phps-mode-parser-sdt-symbol-table)
+                  (puthash
+                   scope-uri
+                   (list phps-mode-parser-sdt-symbol-table-index)
+                   phps-mode-parser-sdt-symbol-table-by-uri)
                   (push
                    `(,scope-uri . ,scope-start)
                    phps-mode-parser-sdt-symbol-imenu))))
              (scope-trait
               (let ((scope-uri
                      (format
-                      "%s trait %s function %s"
+                      "trait %s function %s"
                       (nth 0 scope-trait)
                       (nth 0 scope-function)))
                     (scope-start (nth 1 scope-function))
@@ -1116,6 +1164,10 @@
                     scope-start
                     scope-end)
                    phps-mode-parser-sdt-symbol-table)
+                  (puthash
+                   scope-uri
+                   (list phps-mode-parser-sdt-symbol-table-index)
+                   phps-mode-parser-sdt-symbol-table-by-uri)
                   (push
                    `(,scope-uri . ,scope-start)
                    phps-mode-parser-sdt-symbol-imenu))))
@@ -1138,6 +1190,10 @@
                     scope-start
                     scope-end)
                    phps-mode-parser-sdt-symbol-table)
+                  (puthash
+                   scope-uri
+                   (list phps-mode-parser-sdt-symbol-table-index)
+                   phps-mode-parser-sdt-symbol-table-by-uri)
                   (push
                    `(,scope-uri . ,scope-start)
                    phps-mode-parser-sdt-symbol-imenu)))
@@ -1160,6 +1216,10 @@
                     scope-start
                     scope-end)
                    phps-mode-parser-sdt-symbol-table)
+                  (puthash
+                   scope-uri
+                   (list phps-mode-parser-sdt-symbol-table-index)
+                   phps-mode-parser-sdt-symbol-table-by-uri)
                   (push
                    `(,scope-uri . ,scope-start)
                    phps-mode-parser-sdt-symbol-imenu))))))))
@@ -2677,7 +2737,7 @@
    ;; unless a namespace exists, in that case it should be placed second in 
scope
    (let ((class-name (nth 1 args))
          (class-start (car (cdr (nth 1 terminals))))
-         (class-end (car (cdr (cdr (nth 7 terminals))))))
+         (class-end (cdr (cdr (nth 7 terminals)))))
      (when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
        (dolist (
                 symbol-list
@@ -2772,7 +2832,7 @@
    ;; unless a namespace exists, in that case it should be placed second in 
scope
    (let ((class-name (nth 1 args))
          (class-start (car (cdr (nth 1 terminals))))
-         (class-end (car (cdr (cdr (nth 5 terminals))))))
+         (class-end (cdr (cdr (nth 5 terminals)))))
      (when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
        (dolist (
                 symbol-list
@@ -2853,7 +2913,7 @@
    ;; unless a namespace exists, in that case it should be placed second in 
scope
    (let ((class-name (nth 1 args))
          (class-start (car (cdr (nth 1 terminals))))
-         (class-end (car (cdr (cdr (nth 1 terminals))))))
+         (class-end (cdr (cdr (nth 1 terminals)))))
      (when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
        (dolist (
                 symbol-list
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 94ca40ae78..e54943cbb2 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -147,8 +147,8 @@
   (phps-mode-test-ast--should-bookkeep
    "<?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"
-   '(((8 13) 1) ((40 44) 3) ((157 162) 5) ((113 118) 0) ((71 75) 3) ((52 57) 
5) ((216 220) 12) ((275 279) 12) ((232 236) 0) ((316 320) 0) ((347 352) 1))
-   '(("id $var2" . 8) ("function myFunction id $var" . 40) ("function 
myFunction id $var3" . 52) ("function myFunction2 id $abc" . 216)))
+   '(((8 13) 1) ((40 44) 3) ((157 162) 4) ((113 118) 0) ((71 75) 3) ((52 57) 
4) ((216 220) 6) ((275 279) 6) ((232 236) 0) ((316 320) 0) ((347 352) 1))
+   '(("id $var2" . 8) ("function myFunction" . 29) ("function myFunction id 
$var" . 40) ("function myFunction id $var3" . 52) ("function myFunction2" . 
204) ("function myFunction2 id $abc" . 216)))
 
   (phps-mode-test-ast--should-bookkeep
    "<?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}\nif ($_ENV) {\n    echo 'Hit';\n}\nif ($argc) {\n    echo 
'Hit';\n}\nif ($argv) {\n    echo 'Hit';\n}\nif ($http_​response_​header) {\n   
 echo 'Hit';\n}"
@@ -158,8 +158,8 @@
   (phps-mode-test-ast--should-bookkeep
    "<?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 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) ( [...]
+   '(((37 41) 2) ((485 490) 5) ((881 886) 7) ((814 819) 5) ((746 751) 0) ((678 
683) 0) ((610 615) 0) ((543 547) 0) ((514 519) 7) ((142 147) 9) ((394 399) 10) 
((327 332) 9) ((259 264) 0) ((192 196) 0) ((163 168) 10) ((86 91) 11) ((957 
961) 2) ((999 1004) 0) ((1043 1048) 0) ((1087 1092) 0) ((1131 1136) 0) ((1175 
1180) 0) ((1243 1248) 13) ((2088 2094) 16) ((2894 2900) 16) ((2826 2832) 18) 
((2757 2763) 0) ((2689 2694) 0) ((2621 2626) 0) ((2553 2558) 0) ((2486 2491) 0) 
((2419 2424) 0) ((2351  [...]
+   '(("namespace myNamespaceA" . 18) ("namespace myNamespaceA id $var" . 37) 
("namespace myNamespaceA class myClassA" . 59) ("namespace myNamespaceA class 
myClassA function myFunctionB" . 500) ("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" . 1 [...]
 
   (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 ( [...]
@@ -170,8 +170,8 @@
   (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"
-   '(((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)))
+   '(((639 643) 0) ((632 637) 3) ((578 582) 4) ((571 576) 3) ((517 521) 5) 
((510 515) 3) ((455 460) 6) ((392 397) 6) ((330 335) 0) ((270 274) 7) ((263 
268) 3) ((208 213) 3) ((160 165) 4) ((145 150) 5) ((127 132) 6) ((93 98) 7) 
((751 756) 0))
+   '(("class myClass" . 54) ("class myClass function __construct" . 194) 
("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"
@@ -188,8 +188,8 @@
   (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"
-   '(((121 127) 0) ((114 119) 1) ((89 94) 1))
-   '(("class myClass function __construct id $this" . 79)))
+   '(((121 127) 0) ((114 119) 3) ((89 94) 3))
+   '(("class myClass" . 13) ("class myClass function __construct" . 79) 
("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}"
@@ -206,8 +206,8 @@
   (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"
-   '(((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)))
+   '(((8 12) 1) ((35 39) 3) ((117 122) 4) ((75 79) 5) ((60 65) 0) ((54 58) 1))
+   '(("id $var" . 8) ("function test" . 30) ("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;"
@@ -235,14 +235,14 @@
   (phps-mode-test-ast--should-bookkeep
    "<?php\ninterface myInterface\n{\n    function myFunction1();\n    function 
myFunction2($x);\n}\n"
    "Bookkeeping variable in interface function"
-   '(((84 86) 1))
-   '(("interface myInterface function myFunction2 id $x" . 84)))
+   '(((84 86) 3))
+   '(("interface myInterface" . 17) ("interface myInterface function 
myFunction2") ("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"
-   '(((50 52) 1) ((143 145) 0) ((103 105) 2) ((87 89) 2))
-   '(("function myFunction1 id $a" . 50) ("function myFunction2 id $b" . 87)))
+   '(((50 52) 2) ((143 145) 0) ((103 105) 4) ((87 89) 4))
+   '(("function myFunction1" . 17) ("function myFunction1 id $a" . 50) 
("function myFunction2" . 67) ("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"
@@ -265,32 +265,32 @@
   (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"
-   '(((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 (2)" . 61) ("function myFunction id $f (2)" . 57)))
+   '(((40 42) 2) ((36 38) 3) ((32 34) 4) ((28 30) 5) ((320 322) 2) ((256 258) 
3) ((192 194) 4) ((128 130) 5) ((105 107) 6) ((79 81) 7) ((61 63) 0) ((57 59) 
0))
+   '(("function myFunction" . 17) ("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 (2)" . 61) 
("function myFunction id $f (2)" . 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"
-   '(((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)))
+   '(((8 12) 1) ((35 39) 3) ((68 72) 4) ((54 58) 4))
+   '(("id $var" . 8) ("function test" . 30) ("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"
-   '(((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)))
+   '(((19 21) 1) ((15 17) 2) ((28 30) 2) ((73 75) 4) ((142 144) 0) ((102 104) 
5) ((90 92) 2))
+   '(("id $b" . 19) ("id $a" . 15) ("function myFunction" . 62) ("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"
-   '(((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)))
+   '(((15 17) 1) ((24 26) 1) ((73 75) 3) ((61 63) 3) ((154 156) 7) ((138 140) 
7))
+   '(("id $a" . 15) ("function test" . 41) ("function test id $a" . 61) 
("class There" . 89) ("class There function here" . 121) ("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"
-   '(((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)))
+   '(((462 472) 4) ((429 439) 5) ((396 406) 6) ((364 373) 0) ((357 362) 3) 
((331 340) 7) ((324 329) 3) ((298 307) 8) ((291 296) 3) ((266 274) 9) ((259 
264) 3) ((209 219) 4) ((171 181) 5) ((129 139) 6) ((98 108) 7) ((67 77) 8) ((33 
42) 9))
+   '(("class There" . 13) ("class There function here" . 245) ("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}"
@@ -301,44 +301,44 @@
   (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"
-   '(((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)))
+   '(((464 474) 4) ((431 441) 5) ((398 408) 6) ((366 375) 0) ((359 364) 3) 
((333 342) 7) ((326 331) 3) ((300 309) 8) ((293 298) 3) ((268 276) 9) ((261 
266) 3) ((211 221) 4) ((172 182) 5) ((130 140) 6) ((99 109) 7) ((68 78) 8) ((33 
42) 9))
+   '(("class There" . 13) ("class There function here" . 247) ("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"
-   '(((153 158) 1) ((68 73) 0))
-   '(("class MyClass function there id $this" . 139)))
+   '(((153 158) 3) ((68 73) 0))
+   '(("class MyClass" . 13) ("class MyClass function there" . 139) ("class 
MyClass function there id $this" . 139) ("class MyClass function here" . 54)))
 
   (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"
-   '(((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)))
+   '(((76 78) 3) ((104 106) 5) ((130 132) 5) ((125 127) 3) ((118 122) 6) ((111 
116) 4) ((36 41) 6) ((143 145) 7) ((168 170) 7))
+   '(("class myClass" . 14) ("class myClass function test" . 84) ("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"
-   '(((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)))
+   '(((78 80) 3) ((106 108) 4) ((131 133) 4) ((126 128) 3) ((119 123) 5) ((35 
39) 5))
+  '(("class myClass" . 14) ("class myClass function myMethod" . 86) ("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"
-   '(((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 (2)" . 
446) ("namespace myNamespace class myClass id $property2" . 87) ("namespace 
myNamespace class myClass id [...]
+   '(((180 190) 4) ((160 170) 5) ((140 150) 6) ((544 553) 10) ((537 542) 7) 
((514 524) 6) ((489 498) 10) ((482 487) 7) ((446 456) 6) ((413 423) 0) ((387 
397) 4) ((361 371) 5) ((335 345) 6) ((218 227) 9) ((211 216) 7) ((87 97) 9) 
((58 68) 10))
+  '(("namespace myNamespace" . 17) ("namespace myNamespace class myClass" . 
36) ("namespace myNamespace class myClass function myMethod" . 197) ("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 fun [...]
 
   (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"
-   '(((101 104) 2) ((94 99) 1) ((35 39) 2))
-   '(("trait MyTrait function sayHello id $this" . 80) ("trait MyTrait id 
$var" . 35)))
+   '(((101 104) 4) ((94 99) 3) ((35 39) 4))
+   '(("trait MyTrait" . 13) ("trait MyTrait function sayHello" . 80) ("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."
-   '(((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)))
+   '(((126 134) 3) ((105 109) 5) ((78 83) 7))
+   '(("class Person" . 13) ("class Person function __construct") ("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. --"))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]