diff --git a/PhpCollective/Sniffs/Formatting/ArrayDeclarationSniff.php b/PhpCollective/Sniffs/Formatting/ArrayDeclarationSniff.php index 4016f01..24b6203 100644 --- a/PhpCollective/Sniffs/Formatting/ArrayDeclarationSniff.php +++ b/PhpCollective/Sniffs/Formatting/ArrayDeclarationSniff.php @@ -593,9 +593,10 @@ protected function processMultiLineIndentation(File $phpcsFile, int $arrayStart, } } + $assocModeWithAssociative = $this->multiLineIndentationMode === 'assoc' && $hasAssociative; if ($this->multiLineIndentationMode === 'all') { $shouldProcess = true; - } elseif ($this->multiLineIndentationMode === 'assoc' && $hasAssociative) { + } elseif ($assocModeWithAssociative) { // In 'assoc' mode with associative items $shouldProcess = true; } elseif ($this->maxNonAssocItemsPerLine > 0 && $nonAssocCount > $this->maxNonAssocItemsPerLine) { @@ -613,7 +614,7 @@ protected function processMultiLineIndentation(File $phpcsFile, int $arrayStart, if ($this->multiLineIndentationMode === 'all') { $shouldFlag = true; - } elseif ($this->multiLineIndentationMode === 'assoc' && $hasAssociative) { + } elseif ($assocModeWithAssociative) { // In 'assoc' mode with mixed items, only skip non-associative if no limit exceeded if ($pair['is_associative'] || ($this->maxNonAssocItemsPerLine > 0 && $nonAssocCount > $this->maxNonAssocItemsPerLine)) { $shouldFlag = true;