Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
coder
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
coder
Commits
f606589e
Unverified
Commit
f606589e
authored
1 week ago
by
Klaus Purer
Committed by
GitHub
1 week ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(DocComment): Allow phpcs:ignore directives between param comments (
#3526455
)
parent
e8d5f31e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php
+6
-1
6 additions, 1 deletion
coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php
tests/Drupal/good/good.php
+27
-0
27 additions, 0 deletions
tests/Drupal/good/good.php
with
33 additions
and
1 deletion
coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php
+
6
−
1
View file @
f606589e
...
...
@@ -406,8 +406,12 @@ class DocCommentSniff implements Sniff
continue
;
}
// Search for the previous comment string but also allow for
// PHPCS ignore comments. If we encounter ignore comments then
// we need to be more lenient later by checking if $prev is an
// ignore comment.
$prev
=
$phpcsFile
->
findPrevious
(
T_DOC_COMMENT_STRING
,
([
T_DOC_COMMENT_STRING
=>
T_DOC_COMMENT_STRING
]
+
Tokens
::
$phpcsCommentTokens
)
,
(
$tag
-
1
),
$tokens
[
$commentStart
][
'comment_tags'
][(
$pos
-
1
)]
);
...
...
@@ -442,6 +446,7 @@ class DocCommentSniff implements Sniff
}
else
if
(
$isNewGroup
===
false
&&
(
in_array
(
$currentTag
,
$checkTags
)
===
true
||
in_array
(
$previousTag
,
$checkTags
)
===
true
)
&&
$previousTag
!==
$currentTag
&&
in_array
(
$tokens
[
$prev
][
'code'
],
Tokens
::
$phpcsCommentTokens
)
===
false
)
{
$error
=
'Separate the %s and %s sections by a blank line.'
;
$fix
=
$phpcsFile
->
addFixableError
(
$error
,
$tag
,
'TagGroupSpacing'
,
[
$previousTag
,
$currentTag
]);
...
...
This diff is collapsed.
Click to expand it.
tests/Drupal/good/good.php
+
27
−
0
View file @
f606589e
...
...
@@ -2020,3 +2020,30 @@ public function ignore_phpstan_comment() {
// @phpstan-ignore-next-line missingType.return
public
function
ignore_phpstan_comment_with_attribute_before
()
{
}
/**
* Test PHPCS ignore comments between param docs.
*/
interface
BreadcrumbBuilderInterface
{
/**
* Whether this breadcrumb builder should be used to build the breadcrumb.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
* phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch
* @param \Drupal\Core\Cache\CacheableMetadata $cacheable_metadata
* The cacheable metadata to add to if your check varies by or depends
* on something. Anything you specify here does not have to be repeated in
* the build() method as it will be merged in automatically.
*
* @return bool
* TRUE if this builder should be used or FALSE to let other builders
* decide.
*
* @todo Uncomment new method parameters before drupal:12.0.0, see
* https://www.drupal.org/project/drupal/issues/3459277.
*/
public
function
applies
(
RouteMatchInterface
$route_match
/* , CacheableMetadata $cacheable_metadata */
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment