branch: externals/phps-mode
commit 0e7eb048002c0e15b8e4315a08d27de35e46ce23
Author: Christian Johansson <christ...@cvj.se>
Commit: Christian Johansson <christ...@cvj.se>

    Passing indentation test for multiple function arguments with default values
---
 phps-mode-indent.el           | 13 +++++++++----
 test/phps-mode-test-indent.el | 12 ++++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index f65b7bfb48..a0eb6b5ae8 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -435,14 +435,19 @@
                ;; $var === true
                ;; or
                ;; $var == 3
+               ;; or
+               ;; $argument1 = 3,
+               ;; $argument2 = 4
+               ;; or
+               ;; function myFunction(
+               ;;     $abc = 3
+               ;; ) {
                ((and
                  (string-match-p
-                  "^[\t ]*$[a-zA-Z0-9_]+[\t ]*[^=]*=\\($\\|[\t ]+\\)"
+                  "^[\t ]*$[a-zA-Z0-9_]+[\t ]*[^=]*=\\($\\|[\t ]+.*[^,;]$\\)"
                   previous-line-string)
                  (not
-                  (string-match-p
-                   ";[\t ]*$"
-                   previous-line-string)))
+                  current-line-starts-with-closing-bracket))
                 (setq
                  new-indentation
                  (+ new-indentation tab-width)))
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index db2903b1e4..df03474b0d 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -340,6 +340,18 @@
      "<?php\nif (true) {\n    foreach ($explode as $exploded) {\n        if 
($i == 0) {\n            $lastName = trim($exploded);\n        } elseif ($i == 
$lastIndex) {\n            $lastQuantity = (int) $exploded;\n            
$matches[] = array(\n                'name' => $lastName,\n                
'quantity' => $lastQuantity\n            );\n        }\n    }\n}\n"
      "Closing bracket on new line after ending statement / expression with 
closing bracket")
 
+    (phps-mode-test-indent--should-equal
+     "<?php\nclass MyClass\n{\n    public function log(\n        $message,\n   
     $level = _INFO_\n    ) {\n    }"
+     "Opening method body after argument with default value")
+
+    (phps-mode-test-indent--should-equal
+     "<?php\nclass MyClass\n{\n    public function log(\n        $message,\n   
     $level = _INFO_,\n        $rate = _BASE_RATE_\n    ) {\n    }"
+     "Opening method body after 2 arguments with default values")
+
+    (phps-mode-test-indent--should-equal
+     "<?php\nclass MyClass\n{\n    public function getOperators()\n    {\n     
   return array(\n            '' => __(\n                'None',\n              
  'domain'\n            ),\n            '-' => __(\n                
'Subtraction',\n                'domain'\n            ),\n            '+' => 
__(\n                'Addition',\n                'domain'\n            ),\n    
    );\n    }\n}\n"
+     "Method that returns multi-line array")
+
   )
 
 (defun phps-mode-test-indent--get-lines-indent-psr-2 ()

Reply via email to