private function scanNextType($string)
    {
        foreach ($this->patterns as $type => $pattern) {
            if (preg_match('/^(' . $pattern . ')/sS', $string, $matches) === 1) {
                return [
                    'type'   => $type,
                    'match'  => $matches[1],
                    'length' => strlen($matches[1]),
                ];
            }
        }

        return null;
    }