Subject: [PATCH] userdiff: support enum keyword in PHP hunk header

From: "USAMI Kenta via GitGitGadget" <[email-masked]>
Date: Tue, 31 Aug 2021 06:01:25 +0000

From: USAMI Kenta <[email-masked]>

"enum" keyword will be introduced in PHP 8.1.
https://wiki.php.net/rfc/enumerations

Signed-off-by: USAMI Kenta <[email-masked]>
---
    userdiff: support enum keyword in PHP hunk header
    
    "enum" keyword will be introduced in PHP 8.1.
    https://wiki.php.net/rfc/enumerations

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1082%2Fzonuexe%2Ffeature%2Fuserdiff-php-enum-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1082/zonuexe/feature/userdiff-php-enum-v1
Pull-Request: https://github.com/git/git/pull/1082

 t/t4018/php-enum | 4 ++++
 userdiff.c       | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 t/t4018/php-enum

diff --git a/t/t4018/php-enum b/t/t4018/php-enum
new file mode 100644
index 00000000000..91a69c1a2bc
--- /dev/null
+++ b/t/t4018/php-enum
@@ -0,0 +1,4 @@
+enum RIGHT: string
+{
+    case Foo = 'ChangeMe';
+}
diff --git a/userdiff.c b/userdiff.c
index d9b2ba752f0..d9ec484d535 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -214,7 +214,7 @@ PATTERNS("perl",
 	 "|<<|<>|<=>|>>"),
 PATTERNS("php",
 	 "^[\t ]*(((public|protected|private|static|abstract|final)[\t ]+)*function.*)$\n"
-	 "^[\t ]*((((final|abstract)[\t ]+)?class|interface|trait).*)$",
+	 "^[\t ]*((((final|abstract)[\t ]+)?class|enum|interface|trait).*)$",
 	 /* -- */
 	 "[a-zA-Z_][a-zA-Z0-9_]*"
 	 "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"

base-commit: c4203212e360b25a1c69467b5a8437d45a373cac
-- 
gitgitgadget