Skip to content

fix(DocComment): Allow phpcs ignore comments before a tag (#3523506) #265

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

Merged
merged 2 commits into from
May 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ public function process(File $phpcsFile, $stackPtr)
if ($tokens[$firstTag]['line'] !== ($tokens[$prev]['line'] + 2)
&& isset($fileShort) === false
&& in_array($tokens[$firstTag]['content'], ['@code', '@link', '@endlink']) === false
&& isset(Tokens::$phpcsCommentTokens[$tokens[$prev]['code']]) === false
) {
$error = 'There must be exactly one blank line before the tags in a doc comment';
$fix = $phpcsFile->addFixableError($error, $firstTag, 'SpacingBeforeTags');
Expand Down
17 changes: 17 additions & 0 deletions tests/Drupal/good/good.php
Original file line number Diff line number Diff line change
Expand Up @@ -1986,3 +1986,20 @@ protected function getFallbackPluginId($plugin_id, array $configuration = []) {
}

}

/**
* Provides a collection of condition plugins.
*/
class ConditionPluginCollection extends DefaultLazyPluginCollection {

/**
* {@inheritdoc}
*
* phpcs:ignore Drupal.Commenting.FunctionComment.MissingReturnComment
* @return \Drupal\Core\Condition\ConditionInterface
*/
public function &get($instance_id) {
return 'x';
}

}