Skip to content

Commit 00f4776

Browse files
committed
Skip {@inheritdoc} inside backticks
1 parent c2540df commit 00f4776

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/Rules/PhpDoc/InvalidInheritDocTagRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
final class InvalidInheritDocTagRule implements Rule
2323
{
2424

25-
private const INLINE_INHERIT_DOC_REGEX = '~(?<![a-zA-Z0-9])\{@inheritDoc\b[^}]*\}~i';
25+
private const INLINE_INHERIT_DOC_REGEX = '~`[^`]*`(*SKIP)(*FAIL)|(?<![a-zA-Z0-9])\{@inheritDoc\b[^}]*\}~i';
2626

2727
public function __construct(
2828
private Lexer $phpDocLexer,

tests/PHPStan/Rules/PhpDoc/data/invalid-inherit-doc-tag.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,16 @@ interface ExtendingInterface extends BaseInterface
323323
public function baseMethod(): int;
324324

325325
}
326+
327+
class InheritDocInsideBackticks
328+
{
329+
330+
/**
331+
* Please do not add `{@inheritdoc}` to this method.
332+
*/
333+
public function methodWithInheritDocInBackticks(): int
334+
{
335+
return 0;
336+
}
337+
338+
}

0 commit comments

Comments
 (0)