function ArrayKeyValue::addValues
1 call to ArrayKeyValue::addValues()
- ArrayKeyValue::__construct in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Helpers/ ArrayKeyValue.php
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Helpers/ ArrayKeyValue.php, line 114
Class
- ArrayKeyValue
- @internal
Namespace
SlevomatCodingStandard\HelpersCode
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::$arrayTokenCodes, true)) {
$i = ArrayHelper::openClosePointers($token)[1];
continue;
}
if ($token['code'] === T_DOUBLE_ARROW) {
$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::$inlineCommentTokenCodes, 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;
}