protected function filter(&$script)
    {
        $filter = array();
        if ($this->getParameter('brackets_newline') == 'true') {
            $filter['#^(\t*)\}\h(else|elseif|catch)(.*)\h\{$#m'] = "$1}
$1$2$3
$1{";
            $filter['#^(\t*)(\w.*)\h\{$#m'] = "$1$2
$1{";
        }
        if ($this->getParameter('remove_closing_comments') == 'true') {
            $filter['#^(\t*)} //.*$#m'] = "$1}";
        }
        if ($this->getParameter('use_whitespace') == 'true') {
            $filter['#\t#'] = str_repeat(' ', $this->getParameter('tab_size'));
        }

        $script = preg_replace(array_keys($filter), array_values($filter), $script);

        if ($this->getParameter('strip_comments') == 'true') {
            $script = self::stripComments($script);
        }
    }