1717class FunctionCommentSniff extends PEARFunctionCommentSniff
1818{
1919
20+ /**
21+ * Whether to skip inheritdoc comments.
22+ *
23+ * @var bool
24+ */
25+ public $ skipIfInheritdoc = false ;
26+
2027 /**
2128 * The current PHP version.
2229 *
@@ -40,6 +47,14 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart)
4047 $ tokens = $ phpcsFile ->getTokens ();
4148 $ return = null ;
4249
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+ }
4358 foreach ($ tokens [$ commentStart ]['comment_tags ' ] as $ tag ) {
4459 if ($ tokens [$ tag ]['content ' ] === '@return ' ) {
4560 if ($ return !== null ) {
@@ -189,6 +204,15 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart)
189204 {
190205 $ tokens = $ phpcsFile ->getTokens ();
191206
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+
192216 foreach ($ tokens [$ commentStart ]['comment_tags ' ] as $ pos => $ tag ) {
193217 if ($ tokens [$ tag ]['content ' ] !== '@throws ' ) {
194218 continue ;
@@ -264,6 +288,15 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
264288
265289 $ tokens = $ phpcsFile ->getTokens ();
266290
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+
267300 $ params = [];
268301 $ maxType = 0 ;
269302 $ maxVar = 0 ;
0 commit comments