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>
This commit is contained in:
Javier Spagnoletti 2020-10-07 03:38:18 +00:00 committed by Junio C Hamano
parent d98273ba77
commit aff92827b5
3 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,7 @@
abstract class Klass
{
abstract public function RIGHT(): ?string
{
return 'ChangeMe';
}
}

7
t/t4018/php-final-method Normal file
View File

@ -0,0 +1,7 @@
class Klass
{
final public function RIGHT(): string
{
return 'ChangeMe';
}
}

View File

@ -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_]*"