branch: externals/phps-mode commit 91fb5402cdb004cef93c9c15231471cc9a437b3a Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Added another failing indentation and made it pass --- phps-mode-indent.el | 63 ++++++++++++++++++++++--------------------- test/phps-mode-test-indent.el | 4 +++ 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/phps-mode-indent.el b/phps-mode-indent.el index f501591519..b3d4c378b1 100644 --- a/phps-mode-indent.el +++ b/phps-mode-indent.el @@ -544,6 +544,37 @@ (+ new-indentation tab-width)))) (goto-char point)) + ;; echo <<<VAR + ;; abc + ;; or + ;; echo <<<'VAR' + ;; abc + ;; or + ;; echo <<<"VAR" + ;; abc + ((string-match-p + "<<<'?\"?[a-zA-Z0-9_]+'?\"?$" + previous-line-string) + (setq + new-indentation + 0)) + + ;; echo 'Something' . + ;; 'something'; + ;; but ignore + ;; print_r($object) + ((and + (string-match-p + "^[\t ]*\\(echo\\|print$\\|print[\t ]+\\|return\\|die\\)" + previous-line-string) + (not + (string-match-p + ";[\t ]*$" + previous-line-string))) + (setq + new-indentation + (+ new-indentation tab-width))) + ;; function myFunction($key, ;; $value) ;; { @@ -649,21 +680,6 @@ ) - ;; echo <<<VAR - ;; abc - ;; or - ;; echo <<<'VAR' - ;; abc - ;; or - ;; echo <<<"VAR" - ;; abc - ((string-match-p - "<<<'?\"?[a-zA-Z0-9_]+'?\"?$" - previous-line-string) - (setq - new-indentation - 0)) - ;; $var = 'A line' . ;; 'something'; ;; or @@ -695,22 +711,6 @@ new-indentation (+ new-indentation tab-width))) - ;; echo 'Something' . - ;; 'something'; - ;; but ignore - ;; print_r($object) - ((and - (string-match-p - "^[\t ]*\\(echo\\|print$\\|print[\t ]+\\|return\\|die\\)" - previous-line-string) - (not - (string-match-p - ";[\t ]*$" - previous-line-string))) - (setq - new-indentation - (+ new-indentation tab-width))) - ;; $variable = array( ;; 'random' => ;; 'hello' @@ -1341,6 +1341,7 @@ ;; or ;; define('_PRIVATE_ROOT_', ;; 'here'); + ;; echo 'here'; ((and previous-line-ends-with-terminus (string= previous-line-ends-with-terminus ";") diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el index 1ea722954f..c949ca262f 100644 --- a/test/phps-mode-test-indent.el +++ b/test/phps-mode-test-indent.el @@ -372,6 +372,10 @@ "<?php\n\nif (\n (is_array($data)\n && !empty($data['index'])\n && (is_a($data['index'], 'Index')\n || is_a($data['Index'], 'Index2')))\n || is_a($data, 'WC_Index')\n) {\n\n}\n" "Line after multi-line condition in parenthesis 2") + (phps-mode-test-indent--should-equal + "<?php\nfunction myFunction()\n{\n return self::getOption('username')\n && self::getOption('password');\n}\n" + "Line after line that started a multi-line return expression") + ) (defun phps-mode-test-indent--get-lines-indent-psr-2 ()