本文整理汇总了PHP中PHPDaemon\Core\Daemon::supported方法的典型用法代码示例。如果您正苦于以下问题:PHP Daemon::supported方法的具体用法?PHP Daemon::supported怎么用?PHP Daemon::supported使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPDaemon\Core\Daemon
的用法示例。
在下文中一共展示了Daemon::supported方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPacket
/**
* @param $p
*/
protected function onPacket($p)
{
if ($p['op'] === 'spawnInstance') {
$fullname = $p['appfullname'];
$fullname = str_replace('-', ':', $fullname);
if (mb_orig_strpos($fullname, ':') === false) {
$fullname .= ':';
}
list($app, $name) = explode(':', $fullname, 2);
Daemon::$appResolver->getInstance($app, $name, true, true);
} elseif ($p['op'] === 'importFile') {
if (!Daemon::$config->autoreimport->value) {
Daemon::$process->gracefulRestart();
return;
}
$path = $p['path'];
Timer::add(function ($event) use($path) {
if (Daemon::supported(Daemon::SUPPORT_RUNKIT_IMPORT)) {
//Daemon::log('--start runkit_import('.$path.')');
runkit_import($path, RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_OVERRIDE);
//Daemon::log('--end runkit_import('.$path.')');
} else {
$this->appInstance->log('Cannot import \'' . $path . '\': runkit_import is not callable.');
}
$event->finish();
}, 5);
} elseif ($p['op'] === 'call') {
if (mb_orig_strpos($p['appfullname'], ':') === false) {
$p['appfullname'] .= ':';
}
list($app, $name) = explode(':', $p['appfullname'], 2);
if ($app = Daemon::$appResolver->getInstance($app, $name)) {
$app->RPCall($p['method'], $p['args']);
}
}
}
示例2: overrideNativeFuncs
/**
* Overrides native PHP functions.
* @return void
*/
protected function overrideNativeFuncs()
{
if (Daemon::supported(Daemon::SUPPORT_RUNKIT_INTERNAL_MODIFY)) {
function define($k, $v)
{
if (defined($k)) {
runkit_constant_redefine($k, $v);
} else {
runkit_constant_add($k, $v);
}
}
$this->override('define');
function header()
{
if (!Daemon::$context instanceof \PHPDaemon\Request\Generic) {
return false;
}
return call_user_func_array([Daemon::$context, 'header'], func_get_args());
}
$this->override('header');
function is_uploaded_file()
{
if (!Daemon::$context instanceof \PHPDaemon\Request\Generic) {
return false;
}
return call_user_func_array([Daemon::$context, 'isUploadedFile'], func_get_args());
}
$this->override('is_uploaded_file');
function move_uploaded_file()
{
if (!Daemon::$context instanceof \PHPDaemon\Request\Generic) {
return false;
}
return call_user_func_array([Daemon::$context, 'moveUploadedFile'], func_get_args());
}
$this->override('move_uploaded_file');
function headers_sent(&$file = null, &$line = null)
{
if (!Daemon::$context instanceof \PHPDaemon\Request\Generic) {
return false;
}
return Daemon::$context->headers_sent($file, $line);
}
//$this->override('headers_sent');
function headers_list()
{
if (!Daemon::$context instanceof \PHPDaemon\Request\Generic) {
return false;
}
return Daemon::$context->headers_list();
}
$this->override('headers_list');
function setcookie()
{
if (!Daemon::$context instanceof \PHPDaemon\Request\Generic) {
return false;
}
return call_user_func_array([Daemon::$context, 'setcookie'], func_get_args());
}
$this->override('setcookie');
/**
* @param callable $cb
*/
function register_shutdown_function($cb)
{
if (!Daemon::$context instanceof \PHPDaemon\Request\Generic) {
return false;
}
return Daemon::$context->registerShutdownFunction($cb);
}
$this->override('register_shutdown_function');
runkit_function_copy('create_function', 'create_function_native');
runkit_function_redefine('create_function', '$arg,$body', 'return \\PHPDaemon\\Core\\Daemon::$process->createFunction($arg,$body);');
}
}