Skip to content

Commit 1ab6316

Browse files
kanagitster
authored andcommitted
userdiff: support new keywords in PHP hunk header
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9992fbd commit 1ab6316

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

t/t4018/php-abstract-class

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
abstract class RIGHT
2+
{
3+
const FOO = 'ChangeMe';
4+
}

t/t4018/php-final-class

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
final class RIGHT
2+
{
3+
const FOO = 'ChangeMe';
4+
}

t/t4018/php-interface

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface RIGHT
2+
{
3+
public function foo($ChangeMe);
4+
}

t/t4018/php-trait

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trait RIGHT
2+
{
3+
public function foo($ChangeMe)
4+
{
5+
return 'foo';
6+
}
7+
}

userdiff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ PATTERNS("perl",
114114
"|<<|<>|<=>|>>"),
115115
PATTERNS("php",
116116
"^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
117-
"^[\t ]*(class.*)$",
117+
"^[\t ]*((((final|abstract)[\t ]+)?class|interface|trait).*)$",
118118
/* -- */
119119
"[a-zA-Z_][a-zA-Z0-9_]*"
120120
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"

0 commit comments

Comments
 (0)