示例#1
0
文件: css.php 项目: noccy80/lepton-ng
    
    public function refactor(RefactorFileset $fileset) {
        $tofunc = reset(explode('(',$this->to));
        $toargs = reset(explode(')',end(explode('(',$this->to))));
        $mod = array();
        foreach($fileset->files as $file) {
            if (file_exists($file.'.rf')) {
                $in = file_get_contents($file.'.rf');
            } else {
                $in = file_get_contents($file);
            }
            foreach($this->from as $from) {
                $func = reset(explode('(',$from));
                $args = reset(explode(')',end(explode('(',$from))));
                if ($args == $toargs) {
                    // Just change function names
                    $ref = str_replace($func.'(',$tofunc.'(',$in);
                }
            }
            if ($ref != $in) {
                $mod[] = $file;
                file_put_contents($file.'.rf', $ref);
            }
        }
        return $mod;
    }

}

refactors::registerRefactor('CssRefactor', 'lepton.refactor.css');
示例#2
0
文件: php.php 项目: noccy80/lepton-ng
    
    public function refactor(RefactorFileset $fileset) {
        $tofunc = reset(explode('(',$this->to));
        $toargs = reset(explode(')',end(explode('(',$this->to))));
        $mod = array();
        foreach($fileset->files as $file) {
            if (file_exists($file.'.rf')) {
                $in = file_get_contents($file.'.rf');
            } else {
                $in = file_get_contents($file);
            }
            foreach($this->from as $from) {
                $func = reset(explode('(',$from));
                $args = reset(explode(')',end(explode('(',$from))));
                if ($args == $toargs) {
                    // Just change function names
                    $ref = str_replace($func.'(',$tofunc.'(',$in);
                }
            }
            if ($ref != $in) {
                $mod[] = $file;
                file_put_contents($file.'.rf', $ref);
            }
        }
        return $mod;
    }

}

refactors::registerRefactor('PhpRefactor', 'lepton.refactor.php');