branch: externals/phps-mode commit 02b69f5398582cb54455157604e144312cda8a1f Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Tests for PSR-2 now passes with new algorithms --- phps-mode-functions.el | 6 +++++- phps-mode-test-functions.el | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index e9e54ec..d1cd4e9 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -466,7 +466,11 @@ (and (string= token ",") (= round-bracket-level (car in-assignment-round-bracket-level))) (and (string= token"]") - (< square-bracket-level (car in-assignment-square-bracket-level)))) + (< square-bracket-level (car in-assignment-square-bracket-level))) + (and (equal token 'T_FUNCTION))) + + ;; NOTE Ending an assignment because of function token is to support PSR-2 Closures + (when phps-mode-functions-verbose (message "Ended assignment")) (pop in-assignment-square-bracket-level) diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index 02f674d..2240251 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -231,7 +231,7 @@ (phps-mode-test-with-buffer "<?php\nnamespace Vendor\\Package;\n\nclass ClassName\n{\n public function aVeryLongMethodName(\n ClassTypeHint $arg1,\n &$arg2,\n array $arg3 = []\n ) {\n // method body\n }\n}" "PSR-2 : 4.4. Method Arguments : Example 2" - (message "Indent: %s" (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent))) + ;; (message "Indent: %s" (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent))) (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (1 0)) (7 (2 0)) (8 (2 0)) (9 (2 0)) (10 (1 0)) (11 (2 0)) (12 (1 0)) (13 (0 0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent))))) (phps-mode-test-with-buffer @@ -298,7 +298,7 @@ (phps-mode-test-with-buffer "<?php\n$foo->bar(\n $arg1,\n function ($arg2) use ($var1) {\n // body\n },\n $arg3\n);" "PSR-2 : 6. Closures : Example 3" - (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (2 0)) (6 (1 0)) (7 (1 0)) (8 (0 0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent))))) + (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (2 0)) (6 (1 0)) (7 (1 0)) (8 (0 0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent))))) ) @@ -774,7 +774,7 @@ (defun phps-mode-test-functions () "Run test for functions." ;; (setq debug-on-error t) - (setq phps-mode-functions-verbose t) + ;; (setq phps-mode-functions-verbose t) (phps-mode-test-functions-get-lines-lindent-if) (phps-mode-test-functions-get-lines-indent-classes) (phps-mode-test-functions-get-lines-indent-inline-if)