-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allow @inheritDoc for implementations of interfaces and abstract methods #168
Comments
Question: what about double/mock classes which extend a functional class ? |
Unfortunately that's not reliably sniffable. PHPCS scans files in an undetermined order and for all plugins using YoastCS, with parallel scanning enabled. To be able to sniff this we'd need to know in advance which abstract methods are in abstract classes and which methods are defined in interfaces, as Unfortunately we don't have access to that information at the start of the scan. And allowing just any method in a class which |
@jrfnl From what I can see PHPCS does load the composer autoloader which means all classes it is scanning should be available for reflection. Using a combination of:
It should be possible to reliably compile a list of methods that may use |
@herregroen Hmm.. that's an interesting idea. I hadn't though of that as in most cases when working with PHPCS you can not presume a Composer install, but with YoastCS we can, of course. Nice. I do wonder how much extra memory that will cost to use and whether autoloading those classes via Composer/Reflection will cause issues with "class already declared", but that's something to figure out when working on this. |
Since PHPCS 3.6.0, the
If we'd want to use this, we would need to extend the upstream sniff and toggle the property depending on whether the class in the file which is being scanned complies with the above mentioned conditions. |
Closing as superseded by the decision to forbid |
We decided that the use of
@inheritDoc
should only be allowed for implementations of interfaces and abstract methods. If@inheritDoc
is used to document any other method/function/class, Yoast CS should throw an error.Slightly related: I've also +1ed this issue on WPCS to ensure no warnings about missing short descriptions will be thrown when we use
@inheritDoc
: WordPress/WordPress-Coding-Standards#1429The text was updated successfully, but these errors were encountered: