REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.63 KB
Close
/opt/cpanel/ea-wappspector/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/ForbiddenCommentsSniff.php
Text
Base64
<?php declare(strict_types = 1); namespace SlevomatCodingStandard\Sniffs\Commenting; use Exception; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use SlevomatCodingStandard\Helpers\DocCommentHelper; use SlevomatCodingStandard\Helpers\FixerHelper; use SlevomatCodingStandard\Helpers\SniffSettingsHelper; use function array_key_exists; use function preg_match; use function preg_replace; use function sprintf; use const T_DOC_COMMENT_OPEN_TAG; class ForbiddenCommentsSniff implements Sniff { public const CODE_COMMENT_FORBIDDEN = 'CommentForbidden'; /** @var list<string> */ public array $forbiddenCommentPatterns = []; /** * @return array<int, (int|string)> */ public function register(): array { return [ T_DOC_COMMENT_OPEN_TAG, ]; } /** * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @param int $docCommentOpenPointer */ public function process(File $phpcsFile, $docCommentOpenPointer): void { $tokens = $phpcsFile->getTokens(); $comments = DocCommentHelper::getDocCommentDescription($phpcsFile, $docCommentOpenPointer); if ($comments === null) { return; } foreach (SniffSettingsHelper::normalizeArray($this->forbiddenCommentPatterns) as $forbiddenCommentPattern) { if (!SniffSettingsHelper::isValidRegularExpression($forbiddenCommentPattern)) { throw new Exception(sprintf('%s is not valid PCRE pattern.', $forbiddenCommentPattern)); } foreach ($comments as $comment) { if (preg_match($forbiddenCommentPattern, $comment->getContent()) === 0) { continue; } $fix = $phpcsFile->addFixableError( sprintf('Documentation comment contains forbidden comment "%s".', $comment->getContent()), $comment->getPointer(), self::CODE_COMMENT_FORBIDDEN, ); if (!$fix) { continue; } $phpcsFile->fixer->beginChangeset(); $fixedDocComment = preg_replace($forbiddenCommentPattern, '', $comment->getContent()); FixerHelper::replace($phpcsFile, $comment->getPointer(), $fixedDocComment); for ($i = $comment->getPointer() - 1; $i > $docCommentOpenPointer; $i--) { $contentWithoutSpaces = preg_replace('~ +$~', '', $tokens[$i]['content'], -1, $replacedCount); if ($replacedCount === 0) { break; } FixerHelper::replace($phpcsFile, $i, $contentWithoutSpaces); } $docCommentContent = ''; for ($i = $docCommentOpenPointer + 1; $i < $tokens[$docCommentOpenPointer]['comment_closer']; $i++) { $token = $phpcsFile->fixer->getTokenContent($i); $docCommentContent .= $token; } if (preg_match('~^[\\s\*]*$~', $docCommentContent) !== 0) { $pointerBeforeDocComment = $docCommentOpenPointer - 1; $contentBeforeWithoutSpaces = preg_replace( '~[\t ]+$~', '', $tokens[$pointerBeforeDocComment]['content'], -1, $replacedCount, ); if ($replacedCount !== 0) { FixerHelper::replace($phpcsFile, $pointerBeforeDocComment, $contentBeforeWithoutSpaces); } FixerHelper::removeBetweenIncluding( $phpcsFile, $docCommentOpenPointer, $tokens[$docCommentOpenPointer]['comment_closer'], ); $pointerAfterDocComment = $tokens[$docCommentOpenPointer]['comment_closer'] + 1; if (array_key_exists($pointerAfterDocComment, $tokens)) { $contentAfterWithoutSpaces = preg_replace( '~^[\r\n]+~', '', $tokens[$pointerAfterDocComment]['content'], -1, $replacedCount, ); if ($replacedCount !== 0) { FixerHelper::replace($phpcsFile, $pointerAfterDocComment, $contentAfterWithoutSpaces); } } } $phpcsFile->fixer->endChangeset(); } } } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 14
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
AbstractRequireOneLineDocComment.php
3.55 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
AnnotationNameSniff.php
6.93 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DeprecatedAnnotationDeclarationSniff.php
1.29 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DisallowCommentAfterCodeSniff.php
4.77 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DisallowOneLinePropertyDocCommentSniff.php
2.65 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DocCommentSpacingSniff.php
25.19 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
EmptyCommentSniff.php
6.25 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ForbiddenAnnotationsSniff.php
3.83 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ForbiddenCommentsSniff.php
3.63 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
InlineDocCommentDeclarationSniff.php
13.98 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RequireOneLineDocCommentSniff.php
568 B
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RequireOneLinePropertyDocCommentSniff.php
1.89 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
UselessFunctionDocCommentSniff.php
3.95 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
UselessInheritDocCommentSniff.php
3.13 KB
lrw-r--r--
2025-09-13 08:53:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).