Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

redefineFunction

class Patch {

private $_code;

public function __construct($include_file = null) {
    if ( $include_file ) {
        $this->includeCode($include_file);
    }
}

public function setCode($code) {
    $this->_code = $code;
}

public function includeCode($path) {

    $fp = fopen($path,'r');
    $contents = fread($fp, filesize($path));
    $contents = str_replace('<?php','',$contents);
    $contents = str_replace('?>','',$contents);
    fclose($fp);        

    $this->setCode($contents);
}

function redefineFunction($new_function) {

    preg_match('/function (.+)(/', $new_function, $aryMatches);
    $func_name = trim($aryMatches[1]);

    if ( preg_match('/((private|protected|public) function '.$func_name.'[wW
]+?)(private|protected|public)/s', $this->_code, $aryMatches) ) {

        $search_code = $aryMatches[1];

        $new_code = str_replace($search_code, $new_function."

", $this->_code);

        $this->setCode($new_code);

        return true;

    } else {

        return false;

    }

}

function getCode() {
    return $this->_code;
}
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Spotify analytics intergration 
Javascript :: hoe to add variable to object in GDscribt 
Javascript :: iterating hashmap angular 
Javascript :: how to make a website send form to you 
Javascript :: material ui hide asterisk 
Javascript :: javascript get local timezone 
Javascript :: exit ios inspector in react native 
Javascript :: Using Scrip as Web app 
Javascript :: what to say to your ex 
Javascript :: amcryption npm package 
Javascript :: allow cookies sent by the client 
Javascript :: version control api nodejs best practices 
Javascript :: ex: Javascript 
Javascript :: CSS overflow table row positioning 
Javascript :: add multiple classes javascript 
Javascript :: mac address validation regex angular 
Javascript :: js window selection get new line 
Javascript :: idenmnify 
Javascript :: Detectando url diferente em nodeJs 
Javascript :: useEffect es6 format 
Javascript :: set value localstorage javascript 
Javascript :: how to create a new react app 
Javascript :: how to ask for leave in js 
Javascript :: js log without newline 
Javascript :: mongoose populate not working 
Javascript :: how to slice one specific element from array in angular 
Javascript :: limpar html string js 
Javascript :: concat and asign operator js 
Javascript :: safari technology 
Javascript :: add codegrepper 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =