17
17
class FunctionCommentSniff extends PEARFunctionCommentSniff
18
18
{
19
19
20
+ /**
21
+ * Whether to skip inheritdoc comments.
22
+ *
23
+ * @var bool
24
+ */
25
+ public $ skipIfInheritdoc = false ;
26
+
20
27
/**
21
28
* The current PHP version.
22
29
*
@@ -40,6 +47,14 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart)
40
47
$ tokens = $ phpcsFile ->getTokens ();
41
48
$ return = null ;
42
49
50
+ if ($ this ->skipIfInheritdoc ) {
51
+ for ($ i = $ commentStart ; $ i <= $ tokens [$ commentStart ]['comment_closer ' ]; $ i ++) {
52
+ $ trimmedContent = strtolower (trim ($ tokens [$ i ]['content ' ]));
53
+ if ($ trimmedContent === '{@inheritdoc} ' ) {
54
+ return ;
55
+ }
56
+ }
57
+ }
43
58
foreach ($ tokens [$ commentStart ]['comment_tags ' ] as $ tag ) {
44
59
if ($ tokens [$ tag ]['content ' ] === '@return ' ) {
45
60
if ($ return !== null ) {
@@ -189,6 +204,15 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart)
189
204
{
190
205
$ tokens = $ phpcsFile ->getTokens ();
191
206
207
+ if ($ this ->skipIfInheritdoc ) {
208
+ for ($ i = $ commentStart ; $ i <= $ tokens [$ commentStart ]['comment_closer ' ]; $ i ++) {
209
+ $ trimmedContent = strtolower (trim ($ tokens [$ i ]['content ' ]));
210
+ if ($ trimmedContent === '{@inheritdoc} ' ) {
211
+ return ;
212
+ }
213
+ }
214
+ }
215
+
192
216
foreach ($ tokens [$ commentStart ]['comment_tags ' ] as $ pos => $ tag ) {
193
217
if ($ tokens [$ tag ]['content ' ] !== '@throws ' ) {
194
218
continue ;
@@ -264,6 +288,15 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
264
288
265
289
$ tokens = $ phpcsFile ->getTokens ();
266
290
291
+ if ($ this ->skipIfInheritdoc ) {
292
+ for ($ i = $ commentStart ; $ i <= $ tokens [$ commentStart ]['comment_closer ' ]; $ i ++) {
293
+ $ trimmedContent = strtolower (trim ($ tokens [$ i ]['content ' ]));
294
+ if ($ trimmedContent === '{@inheritdoc} ' ) {
295
+ return ;
296
+ }
297
+ }
298
+ }
299
+
267
300
$ params = [];
268
301
$ maxType = 0 ;
269
302
$ maxVar = 0 ;
0 commit comments