private function fixRules($rules, $rule, $name, $realName, $subName)
    {
        if (isset($rules[$name])) {
            $key = array_search($name, array_keys($rules));

            $rules = array_slice($rules, 0, $key, true) +
                     array($realName.'_'.$subName => $rule) +
                     array_slice($rules, $key, count($rules) - $key, true);
        }

        return $rules;
    }