本文整理汇总了PHP中Daemon::supported方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::supported方法的具体用法?PHP Daemon::supported怎么用?PHP Daemon::supported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Daemon
的用法示例。
在下文中一共展示了Daemon::supported方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPacket
public function onPacket($p)
{
if ($p['op'] === 'spawnInstance') {
$fullname = $p['appfullname'];
$fullname = str_replace('-', ':', $fullname);
if (strpos($fullname, ':') === false) {
$fullname .= ':';
}
list($app, $name) = explode(':', $fullname, 2);
Daemon::$appResolver->appInstantiate($app, $name);
} elseif ($p['op'] === 'importFile') {
$path = $p['path'];
Daemon_TimedEvent::add(function ($event) use($path) {
$self = Daemon::$process;
if (Daemon::supported(Daemon::SUPPORT_RUNKIT_IMPORT)) {
runkit_import($path, RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_OVERRIDE);
} else {
$this->appInstance->log('Cannot import \'' . $path . '\': runkit_import is not callable.');
}
$event->finish();
}, 5);
} elseif ($p['op'] === 'call') {
if (strpos($p['appfullname'], '-') === false) {
$p['appfullname'] .= '-';
}
list($app, $name) = explode('-', $p['appfullname'], 2);
if ($app = Daemon::$appResolver->getInstanceByAppName($app, $name)) {
$app->RPCall($p['method'], $p['args']);
}
}
}
示例2: overrideNativeFuncs
/**
* Overrides native PHP functions.
* @return void
*/
public function overrideNativeFuncs()
{
if (Daemon::supported(Daemon::SUPPORT_RUNKIT_INTERNAL_MODIFY)) {
runkit_function_rename('header', 'header_native');
function header()
{
if (Daemon::$req && Daemon::$req instanceof HTTPRequest) {
return call_user_func_array(array(Daemon::$req, 'header'), func_get_args());
}
}
runkit_function_rename('is_uploaded_file', 'is_uploaded_file_native');
function is_uploaded_file()
{
if (Daemon::$req && Daemon::$req instanceof HTTPRequest) {
return call_user_func_array(array(Daemon::$req, 'isUploadedFile'), func_get_args());
}
}
runkit_function_rename('move_uploaded_file', 'move_uploaded_file_native');
function move_uploaded_file()
{
if (Daemon::$req && Daemon::$req instanceof HTTPRequest) {
return call_user_func_array(array(Daemon::$req, 'moveUploadedFile'), func_get_args());
}
}
runkit_function_rename('headers_sent', 'headers_sent_native');
function headers_sent()
{
if (Daemon::$req && Daemon::$req instanceof HTTPRequest) {
return Daemon::$req->headers_sent();
}
}
runkit_function_rename('headers_list', 'headers_list_native');
function headers_list()
{
if (Daemon::$req && Daemon::$req instanceof HTTPRequest) {
return Daemon::$req->headers_list();
}
}
runkit_function_rename('setcookie', 'setcookie_native');
function setcookie()
{
if (Daemon::$req && Daemon::$req instanceof HTTPRequest) {
return call_user_func_array(array(Daemon::$req, 'setcookie'), func_get_args());
}
}
register_shutdown_function(array($this, 'shutdown'));
runkit_function_rename('register_shutdown_function', 'register_shutdown_function_native');
function register_shutdown_function($cb)
{
if (Daemon::$req) {
return Daemon::$req->registerShutdownFunction($cb);
}
}
runkit_function_copy('create_function', 'create_function_native');
runkit_function_redefine('create_function', '$arg,$body', 'return __create_function($arg,$body);');
function __create_function($arg, $body)
{
static $cache = array();
static $maxCacheSize = 64;
static $sorter;
if ($sorter === NULL) {
$sorter = function ($a, $b) {
if ($a->hits == $b->hits) {
return 0;
}
return $a->hits < $b->hits ? 1 : -1;
};
}
$crc = crc32($arg . "" . $body);
if (isset($cache[$crc])) {
++$cache[$crc][1];
return $cache[$crc][0];
}
if (sizeof($cache) >= $maxCacheSize) {
uasort($cache, $sorter);
array_pop($cache);
}
$cache[$crc] = array($cb = eval('return function(' . $arg . '){' . $body . '};'), 0);
return $cb;
}
}
}