Skip to content
Snippets Groups Projects
Unverified Commit 032364c9 authored by Klaus Purer's avatar Klaus Purer Committed by GitHub
Browse files

fix(VariableComment): Allow phpcs:ignore comments before member variables (#3477601)

parent c43cb34e
No related branches found
No related tags found
No related merge requests found
......@@ -80,6 +80,8 @@ jobs:
if: ${{ matrix.extra-tests == '1' }}
# In case Drupal core files have known problems that should be
# ignored temporarily, add them with the --ignore option.
# @todo Remove ignore option once Coder 8.3.27 is released and Drupal
# core is updated to that version.
run: |
cd drupal/core
../../vendor/bin/phpcs -p
../../vendor/bin/phpcs -p -s --ignore=lib/Drupal/Core/Entity/EntityType.php,lib/Drupal/Core/Recipe/RecipeInputFormTrait.php,lib/Drupal/Core/Form/FormState.php,modules/migrate/src/Plugin/Migration.php,modules/views/src/ViewExecutable.php,modules/views/src/Plugin/views/style/StylePluginBase.php
......@@ -11,6 +11,7 @@ namespace Drupal\Sniffs\Commenting;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
use PHP_CodeSniffer\Util\Tokens;
/**
* Parses and verifies class property doc comments.
......@@ -38,7 +39,7 @@ class VariableCommentSniff extends AbstractVariableSniff
public function processMemberVar(File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$ignore = [
$ignore = ([
T_PUBLIC => T_PUBLIC,
T_PRIVATE => T_PRIVATE,
T_PROTECTED => T_PROTECTED,
......@@ -57,7 +58,7 @@ class VariableCommentSniff extends AbstractVariableSniff
T_FALSE => T_FALSE,
T_SELF => T_SELF,
T_PARENT => T_PARENT,
];
] + Tokens::$phpcsCommentTokens);
for ($commentEnd = ($stackPtr - 1); $commentEnd >= 0; $commentEnd--) {
if (isset($ignore[$tokens[$commentEnd]['code']]) === true) {
......
......@@ -96,4 +96,10 @@ class Test {
*/
protected UserStorageInterface&MockObject $userStorageMock2;
/**
* The search score.
*/
// phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
public string $search_score;
}
......@@ -100,4 +100,10 @@ class Test {
*/
protected UserStorageInterface&MockObject $userStorageMock2;
/**
* The search score.
*/
// phpcs:ignore Drupal.NamingConventions.ValidVariableName.LowerCamelName
public string $search_score;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment