git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] userdiff: support new keywords in PHP hunk header

From
Kana Natsuno <dev@whileimautomaton.net>
Date
Jul 3, 2018, 13:15 UTC
Message-ID
<20180703131540.60789-3-dev@whileimautomaton.net>
In-Reply-To
<20180703131540.60789-1-dev@whileimautomaton.net>

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>
---
 t/t4018/php-abstract-class | 4 ++++
 t/t4018/php-final-class    | 4 ++++
 t/t4018/php-interface      | 4 ++++
 t/t4018/php-trait          | 7 +++++++
 userdiff.c                 | 2 +-
 5 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 t/t4018/php-abstract-class
 create mode 100644 t/t4018/php-final-class
 create mode 100644 t/t4018/php-interface
 create mode 100644 t/t4018/php-trait
diff --git a/t/t4018/php-abstract-class b/t/t4018/php-abstract-class
new file mode 100644
index 0000000..5213e12
--- /dev/null
+++ b/t/t4018/php-abstract-class
@@ -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
index 0000000..69f5710
--- /dev/null
+++ b/t/t4018/php-final-class
@@ -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
index 0000000..86b49ad
--- /dev/null
+++ b/t/t4018/php-interface
@@ -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
index 0000000..65b8c82
--- /dev/null
+++ b/t/t4018/php-trait
@@ -0,0 +1,7 @@
+trait RIGHT
+{
+    public function foo($ChangeMe)
+    {
+        return 'foo';
+    }
+}
diff --git a/userdiff.c b/userdiff.c
index a69241b..36af25e 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -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]+"
-- 
2.10.1 (Apple Git-78)
Previous: Junio C Hamano
Message 4 of 4 in “userdiff: support new keywords in PHP hunk header”
  1. 0/2 userdiff: support new keywords in PHP hunk headerKana Natsuno, Jul 3, 2018
  2. 1/2 t4018: add missing test cases for PHPKana Natsuno, Jul 3, 2018
  3. Junio C HamanoJul 6, 2018
  4. 2/2 userdiff: support new keywords in PHP hunk headerKana Natsuno, Jul 3, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.