Skip to content

Commit e434bd8

Browse files
authored
Merge pull request #706 from PHPCSStandards/feature/abstractarraydeclaration-minor-simplification
AbstractArrayDeclarationSniff::getActualArrayKey(): minor simplification
2 parents 7ec8f55 + f9b2bdb commit e434bd8

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -478,31 +478,15 @@ public function getActualArrayKey(File $phpcsFile, $startPtr, $endPtr)
478478
continue;
479479
}
480480

481-
// Handle FQN true/false/null.
482-
if ($this->tokens[$i]['code'] === \T_NAME_FULLY_QUALIFIED) {
483-
$compareReadyKeyword = \strtolower($this->tokens[$i]['content']);
484-
if ($compareReadyKeyword === '\true'
485-
|| $compareReadyKeyword === '\false'
486-
|| $compareReadyKeyword === '\null'
487-
) {
488-
// FQN true/false/null on PHPCS 4.x. This can be handled.
489-
$content .= $this->tokens[$i]['content'];
490-
continue;
491-
}
492-
} elseif ($this->tokens[$i]['code'] === \T_NS_SEPARATOR) {
493-
// PHPCS 3.x.
481+
// Handle FQN true/false/null for PHPCS 3.x.
482+
if ($this->tokens[$i]['code'] === \T_NS_SEPARATOR) {
494483
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
495484
$nextNonEmptyLC = \strtolower($this->tokens[$nextNonEmpty]['content']);
496485
if ($nextNonEmpty !== false
497-
// PHPCS 3.x with PHP < 8.0.
498486
&& ($this->tokens[$nextNonEmpty]['code'] === \T_TRUE
499487
|| $this->tokens[$nextNonEmpty]['code'] === \T_FALSE
500-
|| $this->tokens[$nextNonEmpty]['code'] === \T_NULL
501-
// PHPCS 3.x with PHP >= 8.0 where the namespaced name tokenization has been undone.
502-
|| ($this->tokens[$nextNonEmpty]['code'] === \T_STRING
503-
&& ($nextNonEmptyLC === 'true' || $nextNonEmptyLC === 'false' || $nextNonEmptyLC === 'null')))
488+
|| $this->tokens[$nextNonEmpty]['code'] === \T_NULL)
504489
) {
505-
// FQN true/false/null on PHPCS 3.x. This can be handled.
506490
$content .= $this->tokens[$nextNonEmpty]['content'];
507491
$i = $nextNonEmpty;
508492
continue;

0 commit comments

Comments
 (0)