You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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.
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
The text was updated successfully, but these errors were encountered: