private function checkArrayStructure(array $invalidCodes, int $searchPos): void
    {
        // Rename the var to get more readable code.
        $remainingInvalidCodes = $invalidCodes;
        unset($invalidCodes);

        foreach ($remainingInvalidCodes as $nextInvalidCodeIndex => $nextInvalidCode) {
            $foundTokenPos = TokenHelper::findNextEffective($this->getFile(), $searchPos);
            $foundToken = $this->tokens[$foundTokenPos];

            // We can stop the search, if there is no invalid code.
            if ($foundToken['code'] !== $nextInvalidCode) {
                break;
            }

            // Check the next possible token
            $searchPos = $foundTokenPos + 1;
            unset($remainingInvalidCodes[$nextInvalidCodeIndex]);
        }

        $matchedEveryInvalidCode = !$remainingInvalidCodes;

        $this->file->recordMetric(
            $searchPos,
            'Invalid array comparison',
            $matchedEveryInvalidCode ? 'yes' : 'no'
        );

        if ($matchedEveryInvalidCode) {
            throw (new CodeError(static::CODE_EMPTY_ARRAY, self::MESSAGE_EMPTY_ARRAY, $searchPos));
        }
    }