From 459f42c7d869211f3dcb82b7f6a684289077331b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 17 Dec 2023 09:41:43 +0100 Subject: [PATCH] Support todo@username comments refs https://github.com/staabm/phpstan-todo-by/issues/3#issuecomment-1857632346 --- src/TodoByRule.php | 1 + tests/TodoByRuleTest.php | 8 ++++++++ tests/data/example.php | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/TodoByRule.php b/src/TodoByRule.php index cb09f4f..baef15c 100644 --- a/src/TodoByRule.php +++ b/src/TodoByRule.php @@ -23,6 +23,7 @@ final class TodoByRule implements Rule private const PATTERN = <<<'REGEXP' / @?TODO # possible @ prefix +@?[a-zA-Z0-9_-]*\s* # optional username \s*[:-]?\s* # optional colon or hyphen (?P\d{4}-\d{2}-\d{2}) # date consisting of YYYY-MM-DD format \s*[:-]?\s* # optional colon or hyphen diff --git a/tests/TodoByRuleTest.php b/tests/TodoByRuleTest.php index a556ec8..351c90c 100644 --- a/tests/TodoByRuleTest.php +++ b/tests/TodoByRuleTest.php @@ -91,6 +91,14 @@ public function testRule(): void 'Expired on 2023-12-14: fix it', 51, ], + [ + 'Expired on 2023-12-14: fix it', + 53, + ], + [ + 'Expired on 2023-12-14: fix it', + 54, + ], ]); } } diff --git a/tests/data/example.php b/tests/data/example.php index ef9dd1e..85ca91e 100644 --- a/tests/data/example.php +++ b/tests/data/example.php @@ -49,3 +49,6 @@ public function XY():void { // @todo 2023-12-14: fix it // todo - 2023-12-14 fix it // todo 2023-12-14 - fix it + +// TODO@lars 2023-12-14 - fix it +// TODO@lars: 2023-12-14 - fix it