userdiff: support new keywords in PHP hunk header
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>
Kana Natsuno committed
Jul 3, 2018 at 22:15 UTC
1ab631647e3addd247c5482e8a3d4c9df7978c62
5 files changed
+20
-1
t/t4018/php-abstract-class
new
+4
@@ -0,0 +1,4 @@
1
+abstract class RIGHT
2
+{
3
+ const FOO = 'ChangeMe';
4
+}
t/t4018/php-final-class
new
+4
@@ -0,0 +1,4 @@
1
+final class RIGHT
2
+{
3
+ const FOO = 'ChangeMe';
4
+}
t/t4018/php-interface
new
+4
@@ -0,0 +1,4 @@
1
+interface RIGHT
2
+{
3
+ public function foo($ChangeMe);
4
+}
t/t4018/php-trait
new
+7
@@ -0,0 +1,7 @@
1
+trait RIGHT
2
+{
3
+ public function foo($ChangeMe)
4
+ {
5
+ return 'foo';
6
+ }
7
+}
userdiff.c
+1
-1
@@ -114,7 +114,7 @@ PATTERNS("perl",
114
"|<<|<>|<=>|>>"),
115
PATTERNS("php",
116
"^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
117
- "^[\t ]*(class.*)$",
117
+ "^[\t ]*((((final|abstract)[\t ]+)?class|interface|trait).*)$",
118
/* -- */
119
"[a-zA-Z_][a-zA-Z0-9_]*"
120
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"