{"thread":{"id":"54354","subject":"[PATCH] Improve diff pattern for PHP files","startedAt":"2020-10-06T10:37:42Z","lastAt":"2020-10-07T18:47:21Z","messageCount":7,"participants":["Javier Spagnoletti via GitGitGadget","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"406988","messageId":"pull.864.git.git.1601980656554.gitgitgadget@gmail.com","threadId":"54354","inReplyTo":null,"subject":"[PATCH] Improve diff pattern for PHP files","fromName":"Javier Spagnoletti via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-06T10:37:36Z","receivedAt":"2020-10-06T10:37:42Z","isPatch":true,"sender":{"key":"name:Javier Spagnoletti","avatar":null},"body":"From: Javier Spagnoletti <phansys@gmail.com>\n\nImprove the output diff readability for php files by taking into account some missing function modifiers.\n\nSigned-off-by: Javier Spagnoletti <phansys@gmail.com>\n---\n    Improve diff pattern for PHP files\n    \n    Improve the output diff readability for php files by taking into account\n    some missing function modifiers.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-864%2Fphansys%2Fuserdiff_php-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-864/phansys/userdiff_php-v1\nPull-Request: https://github.com/git/git/pull/864\n\n userdiff.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex 1df884ef0b..a99d84a7e3 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -143,7 +143,7 @@ PATTERNS(\"perl\",\n \t \"|=~|!~\"\n \t \"|<<|<>|<=>|>>\"),\n PATTERNS(\"php\",\n-\t \"^[\\t ]*(((public|protected|private|static)[\\t ]+)*function.*)$\\n\"\n+\t \"^[\\t ]*(((public|protected|private|static|abstract|final)[\\t ]+)*function.*)$\\n\"\n \t \"^[\\t ]*((((final|abstract)[\\t ]+)?class|interface|trait).*)$\",\n \t /* -- */\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n\nbase-commit: 47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc\n-- \ngitgitgadget\n"},{"id":"406994","messageId":"d262c797-29eb-1e08-8de0-6a2dd2a5d47f@kdbg.org","threadId":"54354","inReplyTo":"pull.864.git.git.1601980656554.gitgitgadget@gmail.com","subject":"Re: [PATCH] Improve diff pattern for PHP files","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-10-06T18:27:06Z","receivedAt":"2020-10-06T18:27:10Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Please choose a commit summary line of the form \"area: summary\", for\nexample:\n\n   userdiff: PHP: catch \"abstract\" and \"final\" functions\n\nAm 06.10.20 um 12:37 schrieb Javier Spagnoletti via GitGitGadget:\n> From: Javier Spagnoletti <phansys@gmail.com>\n> \n> Improve the output diff readability for php files by taking into account some missing function modifiers.\n\n\"Improve\" is a noise word and need not be mentioned; a non-improvement\nwould not be accepted. Also, wrap long lines to at most 72 characters.\nPerhaps:\n\n   PHP permits functions to be defined like\n\n       public final function foo() { }\n       protected abstract function bar() { }\n\n   but our hunk header pattern does not recognize these decorations.\n   Add \"final\" and \"abstract\" to the list of function modifiers.\n\nI am not a PHP expert, so I cannot tell whether what I have written\nabove makes sense.\n\n> \n> Signed-off-by: Javier Spagnoletti <phansys@gmail.com>\n> ---\n>     Improve diff pattern for PHP files\n>     \n>     Improve the output diff readability for php files by taking into account\n>     some missing function modifiers.\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-864%2Fphansys%2Fuserdiff_php-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-864/phansys/userdiff_php-v1\n> Pull-Request: https://github.com/git/git/pull/864\n> \n>  userdiff.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/userdiff.c b/userdiff.c\n> index 1df884ef0b..a99d84a7e3 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -143,7 +143,7 @@ PATTERNS(\"perl\",\n>  \t \"|=~|!~\"\n>  \t \"|<<|<>|<=>|>>\"),\n>  PATTERNS(\"php\",\n> -\t \"^[\\t ]*(((public|protected|private|static)[\\t ]+)*function.*)$\\n\"\n> +\t \"^[\\t ]*(((public|protected|private|static|abstract|final)[\\t ]+)*function.*)$\\n\"\n>  \t \"^[\\t ]*((((final|abstract)[\\t ]+)?class|interface|trait).*)$\",\n>  \t /* -- */\n>  \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n\nIt would be great if you could add test cases to t/4018/ that\ndemonstrate how these new keywords are handled.\n\n-- Hannes\n"},{"id":"406997","messageId":"xmqqpn5v5gml.fsf@gitster.c.googlers.com","threadId":"54354","inReplyTo":"d262c797-29eb-1e08-8de0-6a2dd2a5d47f@kdbg.org","subject":"Re: [PATCH] Improve diff pattern for PHP files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-06T18:55:14Z","receivedAt":"2020-10-06T18:55:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> Please choose a commit summary line of the form \"area: summary\", for\n> example:\n>\n>    userdiff: PHP: catch \"abstract\" and \"final\" functions\n>\n> Am 06.10.20 um 12:37 schrieb Javier Spagnoletti via GitGitGadget:\n>> From: Javier Spagnoletti <phansys@gmail.com>\n>> \n>> Improve the output diff readability for php files by taking into account some missing function modifiers.\n>\n> \"Improve\" is a noise word and need not be mentioned; a non-improvement\n> would not be accepted. Also, wrap long lines to at most 72 characters.\n> Perhaps:\n>\n>    PHP permits functions to be defined like\n>\n>        public final function foo() { }\n>        protected abstract function bar() { }\n>\n>    but our hunk header pattern does not recognize these decorations.\n>    Add \"final\" and \"abstract\" to the list of function modifiers.\n>\n> I am not a PHP expert, so I cannot tell whether what I have written\n> above makes sense.\n\nMe neither, but the new pattern does look like it was written tp\nspecifically allow these combinations.  Thanks for a good example\nlog message to guide new developers with.\n\n>>  PATTERNS(\"php\",\n>> -\t \"^[\\t ]*(((public|protected|private|static)[\\t ]+)*function.*)$\\n\"\n>> +\t \"^[\\t ]*(((public|protected|private|static|abstract|final)[\\t ]+)*function.*)$\\n\"\n>>  \t \"^[\\t ]*((((final|abstract)[\\t ]+)?class|interface|trait).*)$\",\n\nIt probably does not matter in practice, but I wondered what the\nreason for the ordering between final and abstract here (and one\nline above) ;-)\n\n>>  \t /* -- */\n>>  \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n>\n> It would be great if you could add test cases to t/4018/ that\n> demonstrate how these new keywords are handled.\n\nYes.  It seems that we saw another userdiff patch with a test\nupdate recently and that may serve as an example, too.\n\nThanks, both.\n"},{"id":"407022","messageId":"pull.864.v2.git.git.1602041898670.gitgitgadget@gmail.com","threadId":"54354","inReplyTo":"pull.864.git.git.1601980656554.gitgitgadget@gmail.com","subject":"[PATCH v2] Improve diff pattern for PHP files","fromName":"Javier Spagnoletti via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-07T03:38:18Z","receivedAt":"2020-10-07T03:38:24Z","isPatch":true,"sender":{"key":"name:Javier Spagnoletti","avatar":null},"body":"From: Javier Spagnoletti <phansys@gmail.com>\n\nPHP allows some function modifiers that are not recognized in our current hunk header pattern\n\n       final public function foo() { }\n       abstract protected function bar() { }\n\nAdd \"final\" and \"abstract\" to the list of function modifiers.\n\nSigned-off-by: Javier Spagnoletti <phansys@gmail.com>\n---\n    Improve diff pattern for PHP files\n    \n    PHP allows some function modifiers that are not recognized in our\n    current hunk header pattern\n    \n       final public function foo() { }\n       abstract protected function bar() { }\n    \n    Add \"final\" and \"abstract\" to the list of function modifiers. See:\n    \n     * https://www.php.net/manual/en/language.oop5.abstract.php#example-213;\n     * https://www.php.net/manual/en/language.oop5.final.php#language.oop5.traits.static.ex1\n       .\n    \n    Signed-off-by: Javier Spagnoletti phansys@gmail.com [phansys@gmail.com]\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-864%2Fphansys%2Fuserdiff_php-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-864/phansys/userdiff_php-v2\nPull-Request: https://github.com/git/git/pull/864\n\nRange-diff vs v1:\n\n 1:  aa65d43a40 ! 1:  4cb59950ff Improve diff pattern for PHP files\n     @@ Metadata\n       ## Commit message ##\n          Improve diff pattern for PHP files\n      \n     -    Improve the output diff readability for php files by taking into account some missing function modifiers.\n     +    PHP allows some function modifiers that are not recognized in our current hunk header pattern\n     +\n     +           final public function foo() { }\n     +           abstract protected function bar() { }\n     +\n     +    Add \"final\" and \"abstract\" to the list of function modifiers.\n      \n          Signed-off-by: Javier Spagnoletti <phansys@gmail.com>\n      \n     + ## t/t4018/php-abstract-method (new) ##\n     +@@\n     ++abstract class Klass\n     ++{\n     ++    abstract public function RIGHT(): ?string\n     ++    {\n     ++        return 'ChangeMe';\n     ++    }\n     ++}\n     +\n     + ## t/t4018/php-final-method (new) ##\n     +@@\n     ++class Klass\n     ++{\n     ++    final public function RIGHT(): string\n     ++    {\n     ++        return 'ChangeMe';\n     ++    }\n     ++}\n     +\n       ## userdiff.c ##\n      @@ userdiff.c: PATTERNS(\"perl\",\n       \t \"|=~|!~\"\n\n\n t/t4018/php-abstract-method | 7 +++++++\n t/t4018/php-final-method    | 7 +++++++\n userdiff.c                  | 2 +-\n 3 files changed, 15 insertions(+), 1 deletion(-)\n create mode 100644 t/t4018/php-abstract-method\n create mode 100644 t/t4018/php-final-method\n\ndiff --git a/t/t4018/php-abstract-method b/t/t4018/php-abstract-method\nnew file mode 100644\nindex 0000000000..ce215df75a\n--- /dev/null\n+++ b/t/t4018/php-abstract-method\n@@ -0,0 +1,7 @@\n+abstract class Klass\n+{\n+    abstract public function RIGHT(): ?string\n+    {\n+        return 'ChangeMe';\n+    }\n+}\ndiff --git a/t/t4018/php-final-method b/t/t4018/php-final-method\nnew file mode 100644\nindex 0000000000..537fb8ad9a\n--- /dev/null\n+++ b/t/t4018/php-final-method\n@@ -0,0 +1,7 @@\n+class Klass\n+{\n+    final public function RIGHT(): string\n+    {\n+        return 'ChangeMe';\n+    }\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex 1df884ef0b..a99d84a7e3 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -143,7 +143,7 @@ PATTERNS(\"perl\",\n \t \"|=~|!~\"\n \t \"|<<|<>|<=>|>>\"),\n PATTERNS(\"php\",\n-\t \"^[\\t ]*(((public|protected|private|static)[\\t ]+)*function.*)$\\n\"\n+\t \"^[\\t ]*(((public|protected|private|static|abstract|final)[\\t ]+)*function.*)$\\n\"\n \t \"^[\\t ]*((((final|abstract)[\\t ]+)?class|interface|trait).*)$\",\n \t /* -- */\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n\nbase-commit: 47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc\n-- \ngitgitgadget\n"},{"id":"407028","messageId":"xmqqeema4la5.fsf@gitster.c.googlers.com","threadId":"54354","inReplyTo":"pull.864.v2.git.git.1602041898670.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] Improve diff pattern for PHP files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-07T06:12:18Z","receivedAt":"2020-10-07T06:12:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Javier Spagnoletti via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> Subject: Re: [PATCH v2] Improve diff pattern for PHP files\n\nYou seem to have read J6t's excellent suggestion well but forgot to\nretitle.\n\n> From: Javier Spagnoletti <phansys@gmail.com>\n>\n> PHP allows some function modifiers that are not recognized in our current hunk header pattern\n>\n>        final public function foo() { }\n>        abstract protected function bar() { }\n>\n> Add \"final\" and \"abstract\" to the list of function modifiers.\n>\n> Signed-off-by: Javier Spagnoletti <phansys@gmail.com>\n> ...\n>  t/t4018/php-abstract-method | 7 +++++++\n>  t/t4018/php-final-method    | 7 +++++++\n>  userdiff.c                  | 2 +-\n>  3 files changed, 15 insertions(+), 1 deletion(-)\n>  create mode 100644 t/t4018/php-abstract-method\n>  create mode 100644 t/t4018/php-final-method\n>\n> diff --git a/t/t4018/php-abstract-method b/t/t4018/php-abstract-method\n> new file mode 100644\n> index 0000000000..ce215df75a\n> --- /dev/null\n> +++ b/t/t4018/php-abstract-method\n> @@ -0,0 +1,7 @@\n> +abstract class Klass\n> +{\n> +    abstract public function RIGHT(): ?string\n> +    {\n> +        return 'ChangeMe';\n> +    }\n> +}\n> diff --git a/t/t4018/php-final-method b/t/t4018/php-final-method\n> new file mode 100644\n> index 0000000000..537fb8ad9a\n> --- /dev/null\n> +++ b/t/t4018/php-final-method\n> @@ -0,0 +1,7 @@\n> +class Klass\n> +{\n> +    final public function RIGHT(): string\n> +    {\n> +        return 'ChangeMe';\n> +    }\n> +}\n> diff --git a/userdiff.c b/userdiff.c\n> index 1df884ef0b..a99d84a7e3 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -143,7 +143,7 @@ PATTERNS(\"perl\",\n>  \t \"|=~|!~\"\n>  \t \"|<<|<>|<=>|>>\"),\n>  PATTERNS(\"php\",\n> -\t \"^[\\t ]*(((public|protected|private|static)[\\t ]+)*function.*)$\\n\"\n> +\t \"^[\\t ]*(((public|protected|private|static|abstract|final)[\\t ]+)*function.*)$\\n\"\n>  \t \"^[\\t ]*((((final|abstract)[\\t ]+)?class|interface|trait).*)$\",\n>  \t /* -- */\n>  \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n>\n> base-commit: 47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc\n"},{"id":"407080","messageId":"pull.864.v3.git.git.1602094069865.gitgitgadget@gmail.com","threadId":"54354","inReplyTo":"pull.864.v2.git.git.1602041898670.gitgitgadget@gmail.com","subject":"[PATCH v3] userdiff: php: Add \"final\" and \"abstract\" to the list of function modifiers","fromName":"Javier Spagnoletti via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-07T18:07:49Z","receivedAt":"2020-10-07T18:07:57Z","isPatch":true,"sender":{"key":"name:Javier Spagnoletti","avatar":null},"body":"From: Javier Spagnoletti <phansys@gmail.com>\n\nPHP allows some function modifiers that are not recognized in our current hunk header pattern\n\n       final public function foo() { }\n       abstract protected function bar() { }\n\nSome context about the PHP semantics:\n\nIn PHP a class can be declared as abstract and final, while methods can be declared as final,\nstatic and abstract, along with its visibility (public, protected and private).\nRegarding classes, an abstract class can not be declared as final.\nFor the methods, from a strict syntax perspective, the order of the modifiers is irrelevant.\n\nFor more information, see:\n\n* https://www.php.net/manual/en/language.oop5.abstract.php#example-213;\n* https://www.php.net/manual/en/language.oop5.final.php#language.oop5.traits.static.ex1.\n\nThis commit adds \"final\" and \"abstract\" to the list of function modifiers.\n\nSigned-off-by: Javier Spagnoletti <phansys@gmail.com>\n---\n    userdiff: php: Add \"final\" and \"abstract\" to the list of function\n    modifiers\n    \n    PHP allows some function modifiers that are not recognized in our\n    current hunk header pattern\n    \n       final public function foo() { }\n       abstract protected function bar() { }\n    \n    Some context about the PHP semantics:\n    \n    In PHP a class can be declared as abstract and final, while methods can\n    be declared as final, static and abstract, along with its visibility\n    (public, protected and private). Regarding classes, an abstract class\n    can not be declared as final. For the methods, from a strict syntax\n    perspective, the order of the modifiers is irrelevant.\n    \n    For more information, see:\n    \n     * https://www.php.net/manual/en/language.oop5.abstract.php#example-213;\n     * https://www.php.net/manual/en/language.oop5.final.php#language.oop5.traits.static.ex1\n       .\n    \n    This commit adds \"final\" and \"abstract\" to the list of function\n    modifiers.\n    \n    Signed-off-by: Javier Spagnoletti phansys@gmail.com [phansys@gmail.com]\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-864%2Fphansys%2Fuserdiff_php-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-864/phansys/userdiff_php-v3\nPull-Request: https://github.com/git/git/pull/864\n\nRange-diff vs v2:\n\n 1:  4cb59950ff ! 1:  43acd70aba Improve diff pattern for PHP files\n     @@ Metadata\n      Author: Javier Spagnoletti <phansys@gmail.com>\n      \n       ## Commit message ##\n     -    Improve diff pattern for PHP files\n     +    userdiff: php: Add \"final\" and \"abstract\" to the list of function modifiers\n      \n          PHP allows some function modifiers that are not recognized in our current hunk header pattern\n      \n                 final public function foo() { }\n                 abstract protected function bar() { }\n      \n     -    Add \"final\" and \"abstract\" to the list of function modifiers.\n     +    Some context about the PHP semantics:\n     +\n     +    In PHP a class can be declared as abstract and final, while methods can be declared as final,\n     +    static and abstract, along with its visibility (public, protected and private).\n     +    Regarding classes, an abstract class can not be declared as final.\n     +    For the methods, from a strict syntax perspective, the order of the modifiers is irrelevant.\n     +\n     +    For more information, see:\n     +\n     +    * https://www.php.net/manual/en/language.oop5.abstract.php#example-213;\n     +    * https://www.php.net/manual/en/language.oop5.final.php#language.oop5.traits.static.ex1.\n     +\n     +    This commit adds \"final\" and \"abstract\" to the list of function modifiers.\n      \n          Signed-off-by: Javier Spagnoletti <phansys@gmail.com>\n      \n\n\n t/t4018/php-abstract-method | 7 +++++++\n t/t4018/php-final-method    | 7 +++++++\n userdiff.c                  | 2 +-\n 3 files changed, 15 insertions(+), 1 deletion(-)\n create mode 100644 t/t4018/php-abstract-method\n create mode 100644 t/t4018/php-final-method\n\ndiff --git a/t/t4018/php-abstract-method b/t/t4018/php-abstract-method\nnew file mode 100644\nindex 0000000000..ce215df75a\n--- /dev/null\n+++ b/t/t4018/php-abstract-method\n@@ -0,0 +1,7 @@\n+abstract class Klass\n+{\n+    abstract public function RIGHT(): ?string\n+    {\n+        return 'ChangeMe';\n+    }\n+}\ndiff --git a/t/t4018/php-final-method b/t/t4018/php-final-method\nnew file mode 100644\nindex 0000000000..537fb8ad9a\n--- /dev/null\n+++ b/t/t4018/php-final-method\n@@ -0,0 +1,7 @@\n+class Klass\n+{\n+    final public function RIGHT(): string\n+    {\n+        return 'ChangeMe';\n+    }\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex 1df884ef0b..a99d84a7e3 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -143,7 +143,7 @@ PATTERNS(\"perl\",\n \t \"|=~|!~\"\n \t \"|<<|<>|<=>|>>\"),\n PATTERNS(\"php\",\n-\t \"^[\\t ]*(((public|protected|private|static)[\\t ]+)*function.*)$\\n\"\n+\t \"^[\\t ]*(((public|protected|private|static|abstract|final)[\\t ]+)*function.*)$\\n\"\n \t \"^[\\t ]*((((final|abstract)[\\t ]+)?class|interface|trait).*)$\",\n \t /* -- */\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n\nbase-commit: 47ae905ffb98cc4d4fd90083da6bc8dab55d9ecc\n-- \ngitgitgadget\n"},{"id":"407087","messageId":"xmqqpn5t27rj.fsf@gitster.c.googlers.com","threadId":"54354","inReplyTo":"xmqqeema4la5.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v2] Improve diff pattern for PHP files","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-07T18:47:12Z","receivedAt":"2020-10-07T18:47:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> \"Javier Spagnoletti via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n>\n>> Subject: Re: [PATCH v2] Improve diff pattern for PHP files\n>\n> You seem to have read J6t's excellent suggestion well but forgot to\n> retitle.\n\nWill queue with minimum copy-editing (reproduced below).\n\nThanks.\n\ncommit aff92827b54f4b7f9e339982a49bab4bdbd1fc55\nAuthor: Javier Spagnoletti <phansys@gmail.com>\nDate:   Wed Oct 7 03:38:18 2020 +0000\n\n    userdiff: PHP: catch \"abstract\" and \"final\" functions\n    \n    PHP permits functions to be defined like\n    \n           final public function foo() { }\n           abstract protected function bar() { }\n    \n    but our hunk header pattern does not recognize these decorations.\n    Add \"final\" and \"abstract\" to the list of function modifiers.\n    \n    Helped-by: Johannes Sixt <j6t@kdbg.org>\n    Signed-off-by: Javier Spagnoletti <phansys@gmail.com>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\ndiff --git a/t/t4018/php-abstract-method b/t/t4018/php-abstract-method\nnew file mode 100644\nindex 0000000000..ce215df75a\n--- /dev/null\n+++ b/t/t4018/php-abstract-method\n@@ -0,0 +1,7 @@\n+abstract class Klass\n+{\n+    abstract public function RIGHT(): ?string\n+    {\n+        return 'ChangeMe';\n+    }\n+}\ndiff --git a/t/t4018/php-final-method b/t/t4018/php-final-method\nnew file mode 100644\nindex 0000000000..537fb8ad9a\n--- /dev/null\n+++ b/t/t4018/php-final-method\n@@ -0,0 +1,7 @@\n+class Klass\n+{\n+    final public function RIGHT(): string\n+    {\n+        return 'ChangeMe';\n+    }\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex fde02f225b..4e2b55a5e0 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -147,7 +147,7 @@ PATTERNS(\"perl\",\n \t \"|=~|!~\"\n \t \"|<<|<>|<=>|>>\"),\n PATTERNS(\"php\",\n-\t \"^[\\t ]*(((public|protected|private|static)[\\t ]+)*function.*)$\\n\"\n+\t \"^[\\t ]*(((public|protected|private|static|abstract|final)[\\t ]+)*function.*)$\\n\"\n \t \"^[\\t ]*((((final|abstract)[\\t ]+)?class|interface|trait).*)$\",\n \t /* -- */\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n"}]}