csscomb::postprocess PHP Method

postprocess() public method

Постпроцесс, убираем все подстановки и возвращаем на место всё, что мешало сортировке
public postprocess ( )
    function postprocess()
    {
        // 1. экранирование хаков с использованием ключевых символов например voice-family: "\"}\"";
        if (is_array($this->code['hacks'])) {
            // если были обнаружены и вырезаны хаки
            foreach ($this->code['hacks'] as $key => $val) {
                if (strpos($this->code['resorted'], 'hack' . $key . '__')) {
                    $this->code['resorted'] = str_replace('hack' . $key . '__', $val, $this->code['resorted']);
                }
                // заменяем значение expression обратно
            }
        }
        // 2. expressions
        if (is_array($this->code['expressions'])) {
            // если были обнаружены и вырезаны expression
            foreach ($this->code['expressions'] as $key => $val) {
                if (strpos($this->code['resorted'], 'exp' . $key . '__')) {
                    $this->code['resorted'] = str_replace('exp' . $key . '__', 'expression(' . $val . ')', $this->code['resorted']);
                }
                // заменяем значение expression обратно
            }
        }
        // 3. datauri
        if (is_array($this->code['datauri'])) {
            // если были обнаружены и вырезаны data uri
            foreach ($this->code['datauri'] as $key => $val) {
                if (strpos($this->code['resorted'], 'datauri' . $key . '__')) {
                    $this->code['resorted'] = str_replace('datauri' . $key . '__', $val, $this->code['resorted']);
                }
                // заменяем значение expression обратно
            }
        }
        // 4. Interpolated variables
        if (is_array($this->code['interpolations'])) {
            // если были обнаружены и вырезаны data uri
            foreach ($this->code['interpolations'] as $key => $val) {
                $this->code['resorted'] = str_replace('interpolation' . $key . '__', $val[0], $this->code['resorted']);
                // заменяем значение expression обратно
            }
        }
        // Magic comments
        if (is_array($this->code['magicComments'])) {
            foreach ($this->code['magicComments'] as $key => $val) {
                $this->code['resorted'] = str_replace("\nmagic: comment" . $key . '__;', $val[0], $this->code['resorted']);
            }
        }
        // Comments
        if (is_array($this->code['inlinecomments'])) {
            // если были обнаружены и вырезаны data uri
            foreach ($this->code['inlinecomments'] as $key => $val) {
                $this->code['resorted'] = str_replace('inlinecomment' . $key . '__', $val[0], $this->code['resorted']);
                // заменяем значение expression обратно
            }
        }
        if (is_array($this->code['comments'])) {
            // если были обнаружены и вырезаны data uri
            foreach ($this->code['comments'] as $key => $val) {
                if (strpos($this->code['resorted'], 'comment' . $key . '__') > -1) {
                    $this->code['resorted'] = str_replace('comment' . $key . '__', $val[0], $this->code['resorted']);
                    // заменяем значение expression обратно
                }
            }
        }
        // 6. Удаляем искусственно созданные 'brace__'
        if (is_array($this->code['braces'])) {
            // если были обнаружены и вырезаны хаки
            foreach ($this->code['braces'] as $key => $val) {
                if (strpos($this->code['resorted'], 'brace__' . $key . '{') !== FALSE) {
                    $this->code['resorted'] = str_replace('brace__' . $key . '{', $val, $this->code['resorted']);
                }
                if (strpos($this->code['resorted'], '}brace__' . $key) !== FALSE) {
                    $this->code['resorted'] = str_replace('}brace__' . $key, $val, $this->code['resorted']);
                }
            }
        }
        // 7. Entities
        if (is_array($this->code['entities'])) {
            // если были обнаружены и вырезаны entities
            foreach ($this->code['entities'] as $key => $val) {
                if (strpos($this->code['resorted'], 'entity__' . $key) !== FALSE) {
                    $this->code['resorted'] = str_replace('entity__' . $key, $val, $this->code['resorted']);
                }
            }
        }
    }