本文整理汇总了PHP中runkit_function_rename函数的典型用法代码示例。如果您正苦于以下问题:PHP runkit_function_rename函数的具体用法?PHP runkit_function_rename怎么用?PHP runkit_function_rename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runkit_function_rename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: plugin_wix_init
function plugin_wix_init()
{
define('PatternFile', dirname(__FILE__) . '/WixPattern.txt');
require_once $_SERVER['DOCUMENT_ROOT'] . '/wix_cms_newbody.php';
runkit_function_rename('catbody', 'old_catbody');
runkit_function_rename('new_catbody', 'catbody');
}
示例2: teardown
function teardown()
{
runkit_function_rename('unslash', 'html_hilight_test_unslash');
if (function_exists('html_hilight_test_unslash_real')) {
runkit_function_rename('html_hilight_test_unslash_real', 'unslash');
}
}
示例3: getMock
public function getMock()
{
$mock = $this->testCase->getMock('stdClass', $this->functions, array(), 'PHPUnit_Extension_FunctionMocker_' . uniqid());
foreach ($this->functions as $function) {
$fqFunction = $this->namespace . '\\' . $function;
if (in_array($fqFunction, static::$mockedFunctions, true)) {
continue;
}
if (!extension_loaded('runkit') || !ini_get('runkit.internal_override')) {
PHPUnit_Extension_FunctionMocker_CodeGenerator::defineFunction($function, $this->namespace);
} elseif (!function_exists('__phpunit_function_mocker_' . $function)) {
runkit_function_rename($function, '__phpunit_function_mocker_' . $function);
error_log($function);
runkit_method_redefine($function, function () use($function) {
if (!isset($GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'][$this->namespace])) {
return call_user_func_array('__phpunit_function_mocker_' . $function, func_get_args());
}
return call_user_func_array(array($GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'][$this->namespace], $function), func_get_args());
});
var_dump(strlen("foo"));
}
static::$mockedFunctions[] = $fqFunction;
}
if (!isset($GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'])) {
$GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'] = array();
}
$GLOBALS['__PHPUNIT_EXTENSION_FUNCTIONMOCKER'][$this->namespace] = $mock;
return $mock;
}
示例4: teardown
function teardown()
{
global $conf;
// restore purge
if (is_null($this->purge)) {
unset($_REQUEST['purge']);
} else {
$_REQUEST['purge'] = $this->purge;
}
// restore $conf['cachedir'] if necessary
if (!$this->cachedir) {
unset($conf['cachedir']);
}
// restore io_functions
runkit_function_rename('io_makefiledir', 'xhtml_htmlphp_test_io_makefiledir');
if (function_exists('io_makefiledir_real')) {
runkit_function_rename('io_makefiledir_real', 'io_makefiledir');
}
runkit_function_rename('io_savefile', 'xhtml_htmlphp_test_io_savefile');
if (function_exists('io_savefile_real')) {
runkit_function_rename('io_savefile_real', 'io_savefile');
}
// restore GeSHi::parse_code
runkit_method_remove('GeSHi', 'parse_code');
runkit_method_rename('GeSHi', 'parse_code_real', 'parse_code');
parent::setup();
}
示例5: resetFunction
/**
* Reset original function.
*/
public static function resetFunction($function)
{
$originalFunction = "__original_{$function}";
if (function_exists($originalFunction)) {
runkit_function_remove($function);
runkit_function_rename($originalFunction, $function);
}
}
示例6: disable
/**
* Disable
*
* @return \MockFunction
*/
public function disable()
{
if ($this->active) {
$this->active = false;
runkit_function_remove($this->functionName);
runkit_function_rename($this->functionAlias, $this->functionName);
}
return $this;
}
示例7: restore
/**
* Restore
*
* @return \MockFunction
*/
public function restore()
{
if (!$this->_mock) {
return $this;
}
$this->_mock = false;
runkit_function_remove($this->_function_name);
runkit_function_rename($this->_function_alias, $this->_function_name);
return $this;
}
示例8: tearDownAfterClass
public static function tearDownAfterClass()
{
if (self::$skipped) {
return;
}
runkit_function_rename('pinba_timer_start', 'pinba_timer_start_callback');
runkit_function_rename('pinba_timer_stop', 'pinba_timer_stop_callback');
runkit_function_rename('pinba_timer_start_bak', 'pinba_timer_start');
runkit_function_rename('pinba_timer_stop_bak', 'pinba_timer_stop');
}
示例9: tearDown
public function tearDown()
{
if (function_exists('TEST_SAVED_file_get_contents')) {
runkit_function_remove('file_get_contents');
runkit_function_rename('TEST_SAVED_file_get_contents', 'file_get_contents');
}
if (function_exists('TEST_SAVED_stream_context_create')) {
runkit_function_remove('stream_context_create');
runkit_function_rename('TEST_SAVED_stream_context_create', 'stream_context_create');
}
self::$fgcReturn = '{}';
}
示例10: blackMagicBeforeSuite
/**
* @BeforeSuite
*/
public static function blackMagicBeforeSuite(SuiteEvent $event)
{
$parameters = $event->getContextParameters();
if (false === isset($parameters['customDate'])) {
throw new \Exception("You don't have customDate in your behat parameters\n");
}
global $custom_date;
self::$_date = $custom_date = $parameters['customDate'];
$rename = function ($real_name, $fake_name) {
runkit_function_rename($real_name, "real_{$real_name}");
runkit_function_rename("ETNA\\FeatureContext\\{$fake_name}", $real_name);
};
$rename("time", "fakeTime");
$rename("date", "fakeDate");
$rename("strtotime", "fakeStrtotime");
}
示例11: override
/**
* @param string $f
*/
protected function override($f)
{
runkit_function_rename($f, $f . '_native');
runkit_function_rename('PHPDaemon\\Thread\\' . $f, $f);
}
示例12: runkit_function_add
runkit_function_add("time", "", <<<FUNC
\t return original_time() + \$_ENV["{$travelName}"];
FUNC
);
// replace strtotime()
runkit_function_rename("strtotime", "original_strtotime");
runkit_function_add("strtotime", '$time, $now = 0', <<<'FUNC'
if (isset($now)
&& !empty($now))
return original_strtotime($time, $now);
else
return original_strtotime($time, time());
FUNC
);
// replace date()
runkit_function_rename("date", "original_date");
runkit_function_add("date", '$format, $timestamp = 0', <<<'FUNC'
if (isset($timestamp)
&& !empty($timestamp))
return original_date($format, $timestamp);
else
return original_date($format, time());
FUNC
);
return true;
};
if (extension_loaded("uopz")) {
ini_set("uopz.overloads", 1);
return $travelByUopz;
} else {
if (extension_loaded("runkit")) {
示例13: revertRedefinedFunction
/**
* Revert redefenition of the function
*
* @param string $function
*/
public function revertRedefinedFunction($function)
{
$this->checkFunctionExists($function);
$backupFunction = $this->getBackupName($function);
try {
$this->checkFunctionExists($backupFunction);
} catch (PStub_RunkitAdapter_Exception $e) {
throw new PStub_RunkitAdapter_Exception('Function ' . $function . ' was never redefined');
}
runkit_function_remove($function);
runkit_function_rename($backupFunction, $function);
}
示例14: restore
/**
* Removes the mock function implementation and restores
* the previously declared implementation
* @access public
*/
function restore()
{
runkit_function_remove($this->_function) or trigger_error('Error removing mock function', E_USER_ERROR);
runkit_function_rename($this->_tmp_function, $this->_function) or trigger_error('Error restoring real function', E_USER_ERROR);
}
示例15: override
/**
* Override a standard PHP function
* @param string $local e.g. isUploadedFile
* @param string $real e.g. is_uploaded_file
*/
protected function override($camelCase, $real)
{
runkit_function_rename($real, $real . '_native');
runkit_function_rename('PHPDaemon\\Thread\\' . $camelCase, $real);
}