Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traits and docblock inheritance. #128

Closed
ghost opened this issue Mar 10, 2016 · 1 comment
Closed

Traits and docblock inheritance. #128

ghost opened this issue Mar 10, 2016 · 1 comment
Assignees

Comments

@ghost
Copy link

ghost commented Mar 10, 2016

Hello

I have a question regarding docblock inheritance for methods: are docblocks inherited from trait methods? For example, if class C uses trait T, where T defines method foo (with docblock) and C also defines foo (without docblock), does the foo from C inherit the docblock from T? In a certain way, traits are code that is injected into the class, so in essence the original trait method "disappears" from the equation as soon as it's redefined in the class itself, so would docblocks not be inherited in this case?

Similarly, if method foo in trait T does not specify a docblock and C now extends parent class P, which also defines a foo, does the foo from the trait also inherit documentation from the foo in P (and hence, can it use things such as {@inheritdoc} for this purpose)? Using the same logic as above, that would also be the case.

(I accidentally already posted this in the PSR-5 pull request, my apologies.)

Thanks in advance

@ashnazg
Copy link
Member

ashnazg commented Oct 5, 2018

When it comes to docblock inheritance, I believe it is generally assumed that when you override a method without providing a new docblock, you are implying that your override method still meets the documentation in the original method... and thus, your override method should inherit the original docblock.

This opinion would apply to any element that implements/extends/inherits in the code.

@ashnazg ashnazg self-assigned this Oct 5, 2018
@ashnazg ashnazg closed this as completed Oct 5, 2018
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

No branches or pull requests

1 participant