Skip to content

Commit 14eff3c

Browse files
committed
Generic/Todo-Fixme: make the sniffs more selective
The sniffs as-they-were, would sniff all comment related tokens, including `T_DOC_COMMENT_STAR`, `T_DOC_COMMENT_WHITESPACE` etc. Sniffing those tokens is redundant and makes the sniffs slower than is needed. Fixed now by making the tokens being registered by the sniffs more selective/targetted.
1 parent f83010f commit 14eff3c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ The file documents changes to the PHP_CodeSniffer project.
101101
- Runtime performance improvement for PHPCS CLI users. The improvement should be most noticeable for users on Windows.
102102
- Thanks to Juliette Reinders Folmer (@jrfnl) for the patch
103103
- The following sniffs have received performance related improvements:
104+
- Generic.Commenting.Fixme
105+
- Generic.Commenting.Todo
104106
- Generic.PHP.LowerCaseType
105107
- PSR12.Files.OpenTag
106108
- Thanks to Juliette Reinders Folmer (@jrfnl) for the patches

src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ class FixmeSniff implements Sniff
3535
*/
3636
public function register()
3737
{
38-
return array_diff(Tokens::$commentTokens, Tokens::$phpcsCommentTokens);
38+
return [
39+
T_COMMENT,
40+
T_DOC_COMMENT,
41+
T_DOC_COMMENT_TAG,
42+
T_DOC_COMMENT_STRING,
43+
];
3944

4045
}//end register()
4146

src/Standards/Generic/Sniffs/Commenting/TodoSniff.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ class TodoSniff implements Sniff
3434
*/
3535
public function register()
3636
{
37-
return array_diff(Tokens::$commentTokens, Tokens::$phpcsCommentTokens);
37+
return [
38+
T_COMMENT,
39+
T_DOC_COMMENT,
40+
T_DOC_COMMENT_TAG,
41+
T_DOC_COMMENT_STRING,
42+
];
3843

3944
}//end register()
4045

0 commit comments

Comments
 (0)