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: ArrayKeyValue.php
<?php declare(strict_types = 1); namespace SlevomatCodingStandard\Helpers; use PHP_CodeSniffer\Files\File; use function array_reverse; use function current; use function in_array; use function ltrim; use function rtrim; use function strpos; use function trim; use const T_CLOSURE; use const T_COMMA; use const T_DOUBLE_ARROW; use const T_ELLIPSIS; use const T_WHITESPACE; /** * @internal */ class ArrayKeyValue { private int $pointerStart; private int $pointerEnd; private ?string $indent = null; private ?string $key = null; private ?int $pointerArrow = null; private ?int $pointerComma = null; private bool $unpacking = false; public function __construct(File $phpcsFile, int $pointerStart, int $pointerEnd) { $this->pointerStart = $pointerStart; $this->pointerEnd = $pointerEnd; $this->addValues($phpcsFile); } public function getContent(File $phpcsFile, bool $normalize = false, ?string $indent = null): string { if ($normalize === false) { return TokenHelper::getContent($phpcsFile, $this->pointerStart, $this->pointerEnd); } $content = ''; $addCommaPtr = $this->pointerComma === null ? TokenHelper::findPreviousEffective($phpcsFile, $this->pointerEnd) : null; $tokens = $phpcsFile->getTokens(); for ($pointer = $this->pointerStart; $pointer <= $this->pointerEnd; $pointer++) { $token = $tokens[$pointer]; $content .= $token['content']; if ($pointer === $addCommaPtr) { $content .= ','; } } // Trim, but keep leading empty lines $content = ltrim($content, " \t"); $content = rtrim($content); if ($indent !== null && strpos($content, $phpcsFile->eolChar) !== 0) { $content = $indent . $content; } return $content; } public function getIndent(): ?string { return $this->indent; } public function getKey(): ?string { return $this->key; } public function getPointerArrow(): ?int { return $this->pointerArrow; } public function getPointerComma(): ?int { return $this->pointerComma; } public function getPointerEnd(): int { return $this->pointerEnd; } public function getPointerStart(): int { return $this->pointerStart; } public function isUnpacking(): bool { return $this->unpacking; } private function addValues(File $phpcsFile): void { $key = ''; $tokens = $phpcsFile->getTokens(); $firstNonWhitespace = null; for ($i = $this->pointerStart; $i <= $this->pointerEnd; $i++) { $token = $tokens[$i]; if (in_array($token['code'], TokenHelper::ARRAY_TOKEN_CODES, true)) { $i = ArrayHelper::openClosePointers($token)[1]; continue; } if ($token['code'] === T_DOUBLE_ARROW) { if (current(array_reverse($token['conditions'])) === T_CLOSURE) { continue; } $this->pointerArrow = $i; continue; } if ($token['code'] === T_COMMA) { $this->pointerComma = $i; continue; } if ($token['code'] === T_ELLIPSIS) { $this->unpacking = true; continue; } if ($this->pointerArrow !== null) { continue; } if ($firstNonWhitespace === null && $token['code'] !== T_WHITESPACE) { $firstNonWhitespace = $i; } if (in_array($token['code'], TokenHelper::INLINE_COMMENT_TOKEN_CODES, true) === false) { $key .= $token['content']; } } $haveIndent = $firstNonWhitespace !== null && TokenHelper::findFirstNonWhitespaceOnLine( $phpcsFile, $firstNonWhitespace, ) === $firstNonWhitespace; $this->indent = $haveIndent ? TokenHelper::getContent( $phpcsFile, TokenHelper::findFirstTokenOnLine($phpcsFile, $firstNonWhitespace), $firstNonWhitespace - 1, ) : null; $this->key = $this->pointerArrow !== null ? trim($key) : null; } }
Save