REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.13 KB
Close
/opt/cpanel/ea-wappspector/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Commenting/UselessInheritDocCommentSniff.php
Text
Base64
<?php declare(strict_types = 1); namespace SlevomatCodingStandard\Sniffs\Commenting; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use SlevomatCodingStandard\Helpers\FixerHelper; use SlevomatCodingStandard\Helpers\FunctionHelper; use SlevomatCodingStandard\Helpers\TokenHelper; use SlevomatCodingStandard\Helpers\TypeHintHelper; use function in_array; use function preg_match; use const T_ATTRIBUTE; use const T_DOC_COMMENT_OPEN_TAG; use const T_DOC_COMMENT_STAR; use const T_DOC_COMMENT_WHITESPACE; class UselessInheritDocCommentSniff implements Sniff { public const CODE_USELESS_INHERIT_DOC_COMMENT = 'UselessInheritDocComment'; /** * @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(); $docCommentContent = ''; for ($i = $docCommentOpenPointer + 1; $i < $tokens[$docCommentOpenPointer]['comment_closer']; $i++) { if (in_array($tokens[$i]['code'], [T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR], true)) { continue; } $docCommentContent .= $tokens[$i]['content']; } if (preg_match('~^(?:\{@inheritDoc\}|@inheritDoc)$~i', $docCommentContent) === 0) { return; } $searchPointer = $tokens[$docCommentOpenPointer]['comment_closer'] + 1; do { $docCommentOwnerPointer = TokenHelper::findNext( $phpcsFile, [...TokenHelper::FUNCTION_TOKEN_CODES, ...TokenHelper::TYPE_HINT_TOKEN_CODES, T_ATTRIBUTE], $searchPointer, ); if ($docCommentOwnerPointer === null) { return; } if ($tokens[$docCommentOwnerPointer]['code'] === T_ATTRIBUTE) { $searchPointer = $tokens[$docCommentOwnerPointer]['attribute_closer'] + 1; continue; } break; } while (true); if (in_array($tokens[$docCommentOwnerPointer]['code'], TokenHelper::FUNCTION_TOKEN_CODES, true)) { $returnTypeHint = FunctionHelper::findReturnTypeHint($phpcsFile, $docCommentOwnerPointer); if ($returnTypeHint === null) { return; } if (TypeHintHelper::isSimpleIterableTypeHint($returnTypeHint->getTypeHintWithoutNullabilitySymbol())) { return; } $parametersTypeHints = FunctionHelper::getParametersTypeHints($phpcsFile, $docCommentOwnerPointer); foreach ($parametersTypeHints as $parameterTypeHint) { if ($parameterTypeHint === null) { return; } if (TypeHintHelper::isSimpleIterableTypeHint($parameterTypeHint->getTypeHint())) { return; } } } $fix = $phpcsFile->addFixableError( 'Useless documentation comment with @inheritDoc.', $docCommentOpenPointer, self::CODE_USELESS_INHERIT_DOC_COMMENT, ); if (!$fix) { return; } /** @var int $fixerStart */ $fixerStart = TokenHelper::findLastTokenOnPreviousLine($phpcsFile, $docCommentOpenPointer); $phpcsFile->fixer->beginChangeset(); FixerHelper::removeBetweenIncluding($phpcsFile, $fixerStart, $tokens[$docCommentOpenPointer]['comment_closer']); $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).