userdiff: support new keywords in PHP hunk header
cover 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.
Kana Natsuno (2):
t4018: add missing test cases for PHP
userdiff: support new keywords in PHP hunk header
t/t4018/php-abstract-class | 4 ++++ t/t4018/php-class | 4 ++++ t/t4018/php-final-class | 4 ++++ t/t4018/php-function | 4 ++++ t/t4018/php-interface | 4 ++++ t/t4018/php-method | 7 +++++++ t/t4018/php-trait | 7 +++++++ userdiff.c | 2 +- 8 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 t/t4018/php-abstract-class create mode 100644 t/t4018/php-class create mode 100644 t/t4018/php-final-class create mode 100644 t/t4018/php-function create mode 100644 t/t4018/php-interface create mode 100644 t/t4018/php-method create mode 100644 t/t4018/php-trait
Signature · 1 line
2.10.1 (Apple Git-78)
PATCH 1/2 t4018: add missing test cases for PHP
A later patch changes the built-in PHP pattern. These test cases demonstrate aspects of the pattern that we do not want to change.
--- t/t4018/php-class | 4 ++++ t/t4018/php-function | 4 ++++ t/t4018/php-method | 7 +++++++ 3 files changed, 15 insertions(+) create mode 100644 t/t4018/php-class create mode 100644 t/t4018/php-function create mode 100644 t/t4018/php-method
t/t4018/php-class new file +4 -0
@@ -0,0 +1,4 @@ +class RIGHT +{ + const FOO = 'ChangeMe'; +}
t/t4018/php-function new file +4 -0
@@ -0,0 +1,4 @@ +function RIGHT() +{ + return 'ChangeMe'; +}
t/t4018/php-method new file +7 -0
@@ -0,0 +1,7 @@ +class Klass +{ + public static function RIGHT() + { + return 'ChangeMe'; + } +}
Signature · 1 line
2.10.1 (Apple Git-78)
Re: [PATCH 1/2] t4018: add missing test cases for PHP
Quoted 39 lines · Kana Natsuno
A later patch changes the built-in PHP pattern. These test cases demonstrate aspects of the pattern that we do not want to change.
Signed-off-by Kana Natsuno <[email protected]>--- t/t4018/php-class | 4 ++++ t/t4018/php-function | 4 ++++ t/t4018/php-method | 7 +++++++ 3 files changed, 15 insertions(+) create mode 100644 t/t4018/php-class create mode 100644 t/t4018/php-function create mode 100644 t/t4018/php-methodt/t4018/php-class new file +4
-0@@ -0,0 +1,4 @@ +class RIGHT +{ + const FOO = 'ChangeMe'; +}t/t4018/php-function new file +4
-0@@ -0,0 +1,4 @@ +function RIGHT() +{ + return 'ChangeMe'; +}t/t4018/php-method new file +0
-0
t/t4018/php-method line 7
Quoted 7 lines
t/t4018/php-method new file +7
-0@@ -0,0 +1,7 @@ +class Klass +{ + public static function RIGHT() + { + return 'ChangeMe'; + } +}
I no longer speak PHP, and certainly not the modern variant, but these examples all look good to me.
Whoever invented the convetion to use RIGHT/ChangeMe in t4018 should get praised---its brilliance shines in new tests like these ;-)
PATCH 2/2 userdiff: support new keywords in PHP hunk header
In reply to Kana NatsunoRecent 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.
--- 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
t/t4018/php-abstract-class new file +4 -0
@@ -0,0 +1,4 @@ +abstract class RIGHT +{ + const FOO = 'ChangeMe'; +}
t/t4018/php-final-class new file +4 -0
@@ -0,0 +1,4 @@ +final class RIGHT +{ + const FOO = 'ChangeMe'; +}
t/t4018/php-interface new file +4 -0
@@ -0,0 +1,4 @@ +interface RIGHT +{ + public function foo($ChangeMe); +}
t/t4018/php-trait new file +7 -0
@@ -0,0 +1,7 @@ +trait RIGHT +{ + public function foo($ChangeMe) + { + return 'foo'; + } +}
userdiff.c +1 -1
@@ -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]+"
Signature · 1 line
2.10.1 (Apple Git-78)