From 9065b2a5acf22a170c67a0fa4d667912f86b7664 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 3 May 2019 00:11:55 +0900 Subject: [PATCH 1/2] Add fn keyword that added in PHP 7.4 (arrow function) --- php-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/php-mode.el b/php-mode.el index d370e084..e1753279 100644 --- a/php-mode.el +++ b/php-mode.el @@ -625,6 +625,7 @@ PHP does not have an \"enum\"-like keyword." "endswitch" "endwhile" "eval" + "fn" ;; NOT c-lambda-kwds "global" "isset" "list" From 32b4943d7371f697d43ec3c6c0579729947e32f5 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Fri, 3 May 2019 00:14:19 +0900 Subject: [PATCH 2/2] Add test for PHP 7.4 arrow function --- php-mode-test.el | 4 ++ tests/7.4/arrow-function.php | 16 ++++++++ tests/7.4/arrow-function.php.faces | 64 ++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 tests/7.4/arrow-function.php create mode 100644 tests/7.4/arrow-function.php.faces diff --git a/php-mode-test.el b/php-mode-test.el index 05b27308..c90176ee 100644 --- a/php-mode-test.el +++ b/php-mode-test.el @@ -973,4 +973,8 @@ Meant for `php-mode-test-issue-503'." (goto-char (point-min)) (should (eq (php-mode-test-in-function-p nil) nil)))) +(ert-deftest php-mode-test-php74-arrow-fn () + "Test highlighting arrow funcsion (short closure syntax) added in PHP 7.4." + (with-php-mode-test ("7.4/arrow-function.php" :faces t))) + ;;; php-mode-test.el ends here diff --git a/tests/7.4/arrow-function.php b/tests/7.4/arrow-function.php new file mode 100644 index 00000000..b8442119 --- /dev/null +++ b/tests/7.4/arrow-function.php @@ -0,0 +1,16 @@ + $x + $y; + +$fn2 = [ + fn($x) => $x + $y +]; + +$z = 1; +$fn3 = fn($x) => fn($y) => $x * $y + $z; diff --git a/tests/7.4/arrow-function.php.faces b/tests/7.4/arrow-function.php.faces new file mode 100644 index 00000000..86adede0 --- /dev/null +++ b/tests/7.4/arrow-function.php.faces @@ -0,0 +1,64 @@ +;; -*- mode: emacs-lisp -*- +((" ") + ("$" . php-variable-sigil) + ("x" . php-variable-name) + (" + ") + ("$" . php-variable-sigil) + ("y" . php-variable-name) + (";\n\n") + ("$" . php-variable-sigil) + ("fn2" . php-variable-name) + (" = [\n ") + ("fn" . php-keyword) + ("(") + ("$" . php-variable-sigil) + ("x" . php-variable-name) + (") => ") + ("$" . php-variable-sigil) + ("x" . php-variable-name) + (" + ") + ("$" . php-variable-sigil) + ("y" . php-variable-name) + ("\n];\n\n") + ("$" . php-variable-sigil) + ("z" . php-variable-name) + (" = 1;\n") + ("$" . php-variable-sigil) + ("fn3" . php-variable-name) + (" = ") + ("fn" . php-keyword) + ("(") + ("$" . php-variable-sigil) + ("x" . php-variable-name) + (") => ") + ("fn" . php-keyword) + ("(") + ("$" . php-variable-sigil) + ("y" . php-variable-name) + (") => ") + ("$" . php-variable-sigil) + ("x" . php-variable-name) + (" * ") + ("$" . php-variable-sigil) + ("y" . php-variable-name) + (" + ") + ("$" . php-variable-sigil) + ("z" . php-variable-name) + (";\n"))