Skip to content

Report @inheritDoc when there is no PHPDoc to inherit from#5583

Open
kubawerlos wants to merge 4 commits intophpstan:2.1.xfrom
6b7562617765726c6f73:invalid-inherit-doc-tag
Open

Report @inheritDoc when there is no PHPDoc to inherit from#5583
kubawerlos wants to merge 4 commits intophpstan:2.1.xfrom
6b7562617765726c6f73:invalid-inherit-doc-tag

Conversation

@kubawerlos
Copy link
Copy Markdown
Contributor

@VincentLanglet
Copy link
Copy Markdown
Contributor

I think we should distinguish two different case

Copy link
Copy Markdown
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct way to find parent methods is ParentMethodHelper.

@kubawerlos
Copy link
Copy Markdown
Contributor Author

@VincentLanglet do you mean as separate rules?

@ondrejmirtes
Copy link
Copy Markdown
Member

Not a class, but an error identifier for sure.

@kubawerlos kubawerlos force-pushed the invalid-inherit-doc-tag branch from bc204fc to fd71add Compare May 2, 2026 13:52
@kubawerlos kubawerlos requested a review from ondrejmirtes May 2, 2026 14:09
@VincentLanglet
Copy link
Copy Markdown
Contributor

Hi @kubawerlos could you rebase and solve the conflict ?

continue;
}

if (preg_match(self::INLINE_INHERIT_DOC_REGEX, $child->text, $matches) !== 1) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we do better ?

I know it'll be an edge case but you won't catch description like

/**
 * Please do not add `{@inheritDoc}` to this method
 */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very good in regex but looking at the test called InheritDocInsideBackticks i'm not sure we understood each other.

My point was that, we might not want to consider that a method with

/**
 * Foo @inheritDoc
 */ 

has an inheritDoc, cause it might be just a comment.
It wasn't related to backticks

(On the opposite,

/**
 * @inheritDoc Bar
 */ 

might be considered as an inherit doc with an extra comment... ; I dunno)

I never use inheritDoc so I can't stay what we can find in codebase.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated test.

@inheritDoc Bar will be tokenised as a tag with extra description.

@kubawerlos kubawerlos force-pushed the invalid-inherit-doc-tag branch from fd71add to 00f4776 Compare May 6, 2026 20:45
@VincentLanglet VincentLanglet requested a review from staabm May 6, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants