protected function splitTypeAndProperties($rule)
    {
        // A nested rule
        if (!mb_strpos($rule, ':[')) {
            $parts = explode('|', $rule);
            $typeName = array_shift($parts);
            return [$typeName, $parts];
        }

        $chars = Helper::stringSplit($rule);

        $level = 0;
        $isFirst = true;
        $typeName = '';
        $parts = [];
        $currentPart = -1;

        foreach ($chars as $char) {
            if ($char == '[') {
                $level++;
            }

            if ($char == ']') {
                $level--;
            }

            if ($char == '|' && $level == 0) {
                $isFirst = false;
                $currentPart++;
                continue;
            }

            if ($isFirst) {
                $typeName .= $char;
                continue;
            }


            if (!isset($parts[$currentPart])) {
                $parts[$currentPart] = '';
            }

            $parts[$currentPart] .= $char;
        }

        return [$typeName, $parts];
    }