Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,31 +478,15 @@ public function getActualArrayKey(File $phpcsFile, $startPtr, $endPtr)
continue;
}

// Handle FQN true/false/null.
if ($this->tokens[$i]['code'] === \T_NAME_FULLY_QUALIFIED) {
$compareReadyKeyword = \strtolower($this->tokens[$i]['content']);
if ($compareReadyKeyword === '\true'
|| $compareReadyKeyword === '\false'
|| $compareReadyKeyword === '\null'
) {
// FQN true/false/null on PHPCS 4.x. This can be handled.
$content .= $this->tokens[$i]['content'];
continue;
}
} elseif ($this->tokens[$i]['code'] === \T_NS_SEPARATOR) {
// PHPCS 3.x.
// Handle FQN true/false/null for PHPCS 3.x.
if ($this->tokens[$i]['code'] === \T_NS_SEPARATOR) {
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
$nextNonEmptyLC = \strtolower($this->tokens[$nextNonEmpty]['content']);
if ($nextNonEmpty !== false
// PHPCS 3.x with PHP < 8.0.
&& ($this->tokens[$nextNonEmpty]['code'] === \T_TRUE
|| $this->tokens[$nextNonEmpty]['code'] === \T_FALSE
|| $this->tokens[$nextNonEmpty]['code'] === \T_NULL
// PHPCS 3.x with PHP >= 8.0 where the namespaced name tokenization has been undone.
|| ($this->tokens[$nextNonEmpty]['code'] === \T_STRING
&& ($nextNonEmptyLC === 'true' || $nextNonEmptyLC === 'false' || $nextNonEmptyLC === 'null')))
|| $this->tokens[$nextNonEmpty]['code'] === \T_NULL)
) {
// FQN true/false/null on PHPCS 3.x. This can be handled.
$content .= $this->tokens[$nextNonEmpty]['content'];
$i = $nextNonEmpty;
continue;
Expand Down