Skip to content

Commit f5ef016

Browse files
author
Nikolay Shapovalov
committed
fix
1 parent c66c7d7 commit f5ef016

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

coder_sniffer/Drupal/Sniffs/Classes/TestSniff.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public function process(File $phpcsFile, $stackPtr)
6464
&& $tokens[$stackPtr + 3]['type'] === 'T_CONSTANT_ENCAPSED_STRING'
6565
&& str_contains($tokens[$stackPtr + 3]['content'], 'hook_')
6666
) {
67-
$phpcsFile->addWarning('Hook name should not start with "hook_" prefix. Hook name used:' . $tokens[$stackPtr + 3]['content'], $stackPtr + 3,'HookAttributePrefixName');
67+
$hookName = $tokens[$stackPtr + 3]['content'];
68+
$phpcsFile->addWarning('Hook name should not start with "hook_" prefix. Hook name used:' . $hookName, $stackPtr + 3,'HookAttributePrefixName');
69+
$phpcsFile->fixer->replaceToken($stackPtr + 3, str_replace('hook_', '', $hookName));
6870
}
6971

7072
}//end process()

tests/Drupal/bad/BadUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ protected function getErrorList(string $testFile): array
384384
849 => 2,
385385
860 => 2,
386386
867 => 1,
387-
871 => 2,
387+
879 => 2,
388388
];
389389
}//end switch
390390

0 commit comments

Comments
 (0)