コード例 #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');