git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Javier Spagnoletti via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Sixt <j6t@kdbg.org>,
	Javier Spagnoletti <phansys@gmail.com>
Subject: Re: [PATCH v2] Improve diff pattern for PHP files
Date: Wed, 07 Oct 2020 11:47:12 -0700	[thread overview]
Message-ID: <xmqqpn5t27rj.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <xmqqeema4la5.fsf@gitster.c.googlers.com> (Junio C. Hamano's message of "Tue, 06 Oct 2020 23:12:18 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> "Javier Spagnoletti via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
>> Subject: Re: [PATCH v2] Improve diff pattern for PHP files
>
> You seem to have read J6t's excellent suggestion well but forgot to
> retitle.

Will queue with minimum copy-editing (reproduced below).

Thanks.

commit aff92827b54f4b7f9e339982a49bab4bdbd1fc55
Author: Javier Spagnoletti <phansys@gmail.com>
Date:   Wed Oct 7 03:38:18 2020 +0000

    userdiff: PHP: catch "abstract" and "final" functions
    
    PHP permits functions to be defined like
    
           final public function foo() { }
           abstract protected function bar() { }
    
    but our hunk header pattern does not recognize these decorations.
    Add "final" and "abstract" to the list of function modifiers.
    
    Helped-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Javier Spagnoletti <phansys@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>

diff --git a/t/t4018/php-abstract-method b/t/t4018/php-abstract-method
new file mode 100644
index 0000000000..ce215df75a
--- /dev/null
+++ b/t/t4018/php-abstract-method
@@ -0,0 +1,7 @@
+abstract class Klass
+{
+    abstract public function RIGHT(): ?string
+    {
+        return 'ChangeMe';
+    }
+}
diff --git a/t/t4018/php-final-method b/t/t4018/php-final-method
new file mode 100644
index 0000000000..537fb8ad9a
--- /dev/null
+++ b/t/t4018/php-final-method
@@ -0,0 +1,7 @@
+class Klass
+{
+    final public function RIGHT(): string
+    {
+        return 'ChangeMe';
+    }
+}
diff --git a/userdiff.c b/userdiff.c
index fde02f225b..4e2b55a5e0 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -147,7 +147,7 @@ PATTERNS("perl",
 	 "|=~|!~"
 	 "|<<|<>|<=>|>>"),
 PATTERNS("php",
-	 "^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
+	 "^[\t ]*(((public|protected|private|static|abstract|final)[\t ]+)*function.*)$\n"
 	 "^[\t ]*((((final|abstract)[\t ]+)?class|interface|trait).*)$",
 	 /* -- */
 	 "[a-zA-Z_][a-zA-Z0-9_]*"

  reply	other threads:[~2020-10-07 18:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06 10:37 [PATCH] Improve diff pattern for PHP files Javier Spagnoletti via GitGitGadget
2020-10-06 18:27 ` Johannes Sixt
2020-10-06 18:55   ` Junio C Hamano
2020-10-07  3:38 ` [PATCH v2] " Javier Spagnoletti via GitGitGadget
2020-10-07  6:12   ` Junio C Hamano
2020-10-07 18:47     ` Junio C Hamano [this message]
2020-10-07 18:07   ` [PATCH v3] userdiff: php: Add "final" and "abstract" to the list of function modifiers Javier Spagnoletti via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqpn5t27rj.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=j6t@kdbg.org \
    --cc=phansys@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).