supported() public static method

Is thing supported
public static supported ( integer $what ) : boolean
$what integer Thing to check
return boolean
Exemplo n.º 1
0
 /**
  * @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']);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 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);');
     }
 }