src/Standards/BestIt/Sniffs/Formatting/UCVFSortingSniff.php
private function validateSorting(array $originalTokens, array $sortedTokens): void
    {
        $sortedPositions = array_keys($sortedTokens);
        $sortedIndex = 0;

        foreach ($originalTokens as $originalPosition => $originalToken) {
            $sortedPosition = $sortedPositions[$sortedIndex++];
            $sortedToken = $sortedTokens[$sortedPosition];

            // We don't need an error if the "type block" is the same, so check the code additionally.
            if (($sortedPosition !== $originalPosition) && ($originalToken['code'] !== $sortedToken['code'])) {
                $this->file->addError(
                    self::MESSAGE_WRONG_POSITION,
                    $originalPosition,
                    static::CODE_WRONG_POSITION,
                    [
                        $sortedToken['type'],
                        $sortedToken['content']
                    ]
                );
            }
        }
    }
private function validateSorting(array $originalTokens, array $sortedTokens): void
    {
        $sortedPositions = array_keys($sortedTokens);
        $sortedIndex = 0;

        foreach ($originalTokens as $originalPosition => $originalToken) {
            $sortedPosition = $sortedPositions[$sortedIndex++];
            $sortedToken = $sortedTokens[$sortedPosition];

            // We don't need an error if the "type block" is the same, so check the code additionally.
            if (($sortedPosition !== $originalPosition) && ($originalToken['code'] !== $sortedToken['code'])) {
                $this->file->addError(
                    self::MESSAGE_WRONG_POSITION,
                    $originalPosition,
                    static::CODE_WRONG_POSITION,
                    [
                        $sortedToken['type'],
                        $sortedToken['content']
                    ]
                );
            }
        }
    }
private function validateSorting ( array $ originalTokens , array $ sortedTokens ) : void { $ sortedPositions = array_keys ( $ sortedTokens ) ; $ sortedIndex = 0 ; foreach ( $ originalTokens as $ originalPosition => $ originalToken ) { $ sortedPosition = $ sortedPositions [ $ sortedIndex ++ ] ; $ sortedToken = $ sortedTokens [ $ sortedPosition ] ; // We don't need an error if the "type block" is the same, so check the code additionally. if ( ( $ sortedPosition !== $ originalPosition ) && ( $ originalToken [ 'code' ] !== $ sortedToken [ 'code' ] ) ) { $ this -> file -> addError ( self :: MESSAGE_WRONG_POSITION , $ originalPosition , static :: CODE_WRONG_POSITION , [ $ sortedToken [ 'type' ] , $ sortedToken [ 'content' ] ] ) ; } } }
Validates the sorting of the tokens and registers an error if wrong sorted.

@param array $originalTokens
@param array $sortedTokens

@return void
Validates the sorting of the tokens and registers an error if wrong sorted .