userdiff: support new keywords in PHP hunk header
authorKana Natsuno <dev@whileimautomaton.net>
Tue, 3 Jul 2018 13:15:40 +0000 (22:15 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Jul 2018 21:59:28 +0000 (14:59 -0700)
Recent version of PHP supports interface, trait, abstract class and
final class. This patch fixes the PHP hunk header regexp to support
all of these keywords.

Signed-off-by: Kana Natsuno <dev@whileimautomaton.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4018/php-abstract-class [new file with mode: 0644]
t/t4018/php-final-class [new file with mode: 0644]
t/t4018/php-interface [new file with mode: 0644]
t/t4018/php-trait [new file with mode: 0644]
userdiff.c
diff --git a/t/t4018/php-abstract-class b/t/t4018/php-abstract-class
new file mode 100644 (file)
index 0000000..5213e12
--- /dev/null
@@ -0,0 +1,4 @@
+abstract class RIGHT
+{
+    const FOO = 'ChangeMe';
+}
diff --git a/t/t4018/php-final-class b/t/t4018/php-final-class
new file mode 100644 (file)
index 0000000..69f5710
--- /dev/null
@@ -0,0 +1,4 @@
+final class RIGHT
+{
+    const FOO = 'ChangeMe';
+}
diff --git a/t/t4018/php-interface b/t/t4018/php-interface
new file mode 100644 (file)
index 0000000..86b49ad
--- /dev/null
@@ -0,0 +1,4 @@
+interface RIGHT
+{
+    public function foo($ChangeMe);
+}
diff --git a/t/t4018/php-trait b/t/t4018/php-trait
new file mode 100644 (file)
index 0000000..65b8c82
--- /dev/null
@@ -0,0 +1,7 @@
+trait RIGHT
+{
+    public function foo($ChangeMe)
+    {
+        return 'foo';
+    }
+}
index a69241b25ddaff5b61380aa8b451a6fcb833502c..36af25e7f9f4693b196320f56bb0546d7dd2986a 100644 (file)
@@ -114,7 +114,7 @@ PATTERNS("perl",
         "|<<|<>|<=>|>>"),
 PATTERNS("php",
         "^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
-        "^[\t ]*(class.*)$",
+        "^[\t ]*((((final|abstract)[\t ]+)?class|interface|trait).*)$",
         /* -- */
         "[a-zA-Z_][a-zA-Z0-9_]*"
         "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"