golden hour
/opt/cpanel/ea-wappspector/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers
⬆️ Go Up
Upload
File/Folder
Size
Actions
Annotation.php
1.11 KB
Del
OK
AnnotationHelper.php
8.67 KB
Del
OK
AnnotationTypeHelper.php
10.15 KB
Del
OK
ArrayHelper.php
6.25 KB
Del
OK
ArrayKeyValue.php
3.6 KB
Del
OK
Attribute.php
1.14 KB
Del
OK
AttributeHelper.php
5 KB
Del
OK
CatchHelper.php
2.18 KB
Del
OK
ClassHelper.php
3.03 KB
Del
OK
Comment.php
430 B
Del
OK
CommentHelper.php
2.52 KB
Del
OK
ConditionHelper.php
10.2 KB
Del
OK
ConstantHelper.php
2.03 KB
Del
OK
DocCommentHelper.php
7.12 KB
Del
OK
EmptyFileException.php
502 B
Del
OK
FixerHelper.php
1.97 KB
Del
OK
FunctionHelper.php
16.55 KB
Del
OK
IdentificatorHelper.php
7.34 KB
Del
OK
IndentationHelper.php
2.84 KB
Del
OK
NamespaceHelper.php
5.8 KB
Del
OK
ParameterHelper.php
893 B
Del
OK
ParsedDocComment.php
2.27 KB
Del
OK
PhpDocParserHelper.php
1.56 KB
Del
OK
PropertyHelper.php
6.39 KB
Del
OK
ReferencedName.php
1.32 KB
Del
OK
ReferencedNameHelper.php
15.13 KB
Del
OK
ScopeHelper.php
1.48 KB
Del
OK
SniffLocalCache.php
1.2 KB
Del
OK
SniffSettingsHelper.php
2.01 KB
Del
OK
StringHelper.php
485 B
Del
OK
SuppressHelper.php
2.27 KB
Del
OK
TernaryOperatorHelper.php
4.97 KB
Del
OK
TokenHelper.php
12.87 KB
Del
OK
TokenPointerOutOfBoundsException.php
774 B
Del
OK
TypeHelper.php
740 B
Del
OK
TypeHint.php
966 B
Del
OK
TypeHintHelper.php
10.67 KB
Del
OK
UseStatement.php
2.53 KB
Del
OK
UseStatementHelper.php
7.82 KB
Del
OK
VariableHelper.php
5.03 KB
Del
OK
YodaHelper.php
9.28 KB
Del
OK
Edit: IndentationHelper.php
<?php declare(strict_types = 1); namespace SlevomatCodingStandard\Helpers; use PHP_CodeSniffer\Files\File; use function floor; use function in_array; use function ltrim; use function preg_replace_callback; use function rtrim; use function str_repeat; use function strlen; use function substr; use const T_END_HEREDOC; use const T_END_NOWDOC; use const T_START_HEREDOC; use const T_START_NOWDOC; /** * @internal */ class IndentationHelper { public const DEFAULT_INDENTATION_WIDTH = 4; public static function getIndentation(File $phpcsFile, int $pointer): string { $firstPointerOnLine = TokenHelper::findFirstTokenOnLine($phpcsFile, $pointer); return TokenHelper::getContent($phpcsFile, $firstPointerOnLine, $pointer - 1); } public static function addIndentation(File $phpcsFile, string $indentation, int $level = 1): string { return $indentation . str_repeat(self::getOneIndentationLevel($phpcsFile), $level); } public static function getOneIndentationLevel(File $phpcsFile): string { return str_repeat(' ', $phpcsFile->config->tabWidth !== 0 ? $phpcsFile->config->tabWidth : self::DEFAULT_INDENTATION_WIDTH); } /** * @param list<int> $codePointers */ public static function removeIndentation(File $phpcsFile, array $codePointers, string $defaultIndentation): string { $tokens = $phpcsFile->getTokens(); $eolLength = strlen($phpcsFile->eolChar); $code = ''; $inHeredoc = false; $indentation = self::getOneIndentationLevel($phpcsFile); $indentationLength = strlen($indentation); foreach ($codePointers as $no => $codePointer) { $content = $tokens[$codePointer]['content']; if ( !$inHeredoc && ( $no === 0 || substr($tokens[$codePointer - 1]['content'], -$eolLength) === $phpcsFile->eolChar ) ) { if ($content === $phpcsFile->eolChar) { // Nothing } elseif (substr($content, 0, $indentationLength) === $indentation) { $content = substr($content, $indentationLength); } else { $content = $defaultIndentation . ltrim($content); } } if (in_array($tokens[$codePointer]['code'], [T_START_HEREDOC, T_START_NOWDOC], true)) { $inHeredoc = true; } elseif (in_array($tokens[$codePointer]['code'], [T_END_HEREDOC, T_END_NOWDOC], true)) { $inHeredoc = false; } $code .= $content; } return rtrim($code); } public static function convertSpacesToTabs(File $phpcsFile, string $code): string { // @codeCoverageIgnoreStart if ($phpcsFile->config->tabWidth === 0) { return $code; } // @codeCoverageIgnoreEnd return preg_replace_callback('~^([ ]+)~m', static function (array $matches) use ($phpcsFile): string { $tabsCount = (int) floor(strlen($matches[1]) / $phpcsFile->config->tabWidth); $spacesCountToRemove = $tabsCount * $phpcsFile->config->tabWidth; return str_repeat("\t", $tabsCount) . substr($matches[1], $spacesCountToRemove); }, $code); } }
Save