Example #1
0
 public static function parse($name, $src, $docendpos = 0)
 {
     $info = new static();
     $info->name($name);
     if ($docendpos > 0) {
         $doc = trim(substr($src, 0, $docendpos));
         $startpos = strrpos($doc, '/**');
         if ($startpos !== false) {
             $doc = substr($doc, $startpos);
             if (preg_match('/\\/\\*\\*(.+?)\\*\\//s', $doc, $m)) {
                 $doc = preg_replace('/^[\\s]*\\*[\\s]{0,1}/m', '', $m[1]);
             } else {
                 $doc = '';
             }
         } else {
             $doc = '';
         }
     } else {
         $doc = $src;
     }
     $params = \ebi\Dt\DocParam::parse('param', $doc);
     if (!empty($params)) {
         $info->params($params);
     }
     if (preg_match("/@return\\s+([^\\s]+)(.*)/", $doc, $m)) {
         $info->return(new \ebi\Dt\DocParam('return', $m[1], $m[2]));
     }
     $info->document(trim(preg_replace('/@.+/', '', preg_replace("/^[\\s]*\\*[\\s]{0,1}/m", '', str_replace('*' . '/', '', $doc)))));
     return $info;
 }
Example #2
0
 public static function __callStatic($name, $arguments)
 {
     if ($name == 'getName') {
         $self = new static();
         return $self->name();
     }
 }
 /**
  * Returns the notifier's name.
  *
  * @return string
  */
 public function getName()
 {
     if (!static::$name) {
         static::$name = str_replace('Notifier', '', join('', array_slice(explode('\\', get_class($this)), -1)));
     }
     return static::$name;
 }
Example #4
0
 public static function factory($name)
 {
     $config = static::service('config');
     $assert = static::service('assert');
     $dbConfig = $config->get('databases.#1', null, $name);
     $assert->notNull($dbConfig);
     $db = new static($dbConfig);
     $db->name($name);
     return $db;
 }
 /**
  * Check the request for the current domain
  *
  * @param Request $request The request object
  */
 public static function setRequest(Request $request)
 {
     $host = strtolower(preg_replace('/^(.*(\\.|\\/))?([^\\.]+\\.[^\\.]+)$/i', '$3', $request->getHost()));
     $sites = Config::get('app.sites');
     $name = Config::get('app.fallback_site');
     foreach ($sites as $site => $settings) {
         $name = in_array($host, $settings['domains']) ? $site : $name;
     }
     static::$name = $name;
 }
Example #6
0
 public function getName()
 {
     if (null !== static::$name) {
         return static::$name;
     }
     $name = get_called_class();
     if ($name !== ($nameSegment = explode('\\', $name))) {
         $name = $nameSegment[count($nameSegment) - 2];
     }
     return static::$name = $name;
 }
Example #7
0
 /**
  * @param string $name
  * @param bool|\Closure $output
  * @param bool $cpu
  * @param bool $memory
  * @param array $ignored
  * @return bool
  */
 public static function start($name = 'xhprof', $output = false, $cpu = true, $memory = true, $ignored = [])
 {
     if (!static::checkEnv()) {
         return false;
     }
     static::$name = $name;
     static::$output = $output;
     $flags = XHPROF_FLAGS_NO_BUILTINS;
     if ($cpu) {
         $flags = $flags | XHPROF_FLAGS_CPU;
     }
     if ($memory) {
         $flags = $flags | XHPROF_FLAGS_MEMORY;
     }
     $ignored = $ignored + [__CLASS__ . '::sendData'];
     xhprof_enable($flags, ['ignored_functions' => $ignored]);
     register_shutdown_function([__CLASS__, 'sendData']);
 }
Example #8
0
 /**
  * Create a route from an array representation
  *
  * @param array $array
  *
  * @return Route
  */
 public static function createFromArray(array $array)
 {
     $route = new static($array['patterns']);
     if (isset($array['name'])) {
         $route->name($array['name']);
     }
     if (isset($array['params'])) {
         $route->params($array['params']);
     }
     if (isset($array['values'])) {
         $route->values($array['values']);
     }
     if (isset($array['conditions'])) {
         $route->conditions($array['conditions']);
     }
     if (isset($array['attributes'])) {
         $route->attributes($array['attributes']);
     }
     return $route;
 }
Example #9
0
 /**
  * Run all new migration
  *
  * @param bool			$silent 		In the silent mode the migrator ignores the migration file
  * 
  * @return void
  */
 public static function migrate($silent = false)
 {
     $migrations = $silent ? static::available() : static::unstaged();
     foreach ($migrations as $key => $value) {
         if (empty($value)) {
             continue;
         }
         if (\ClanCats::is_cli()) {
             \CCCli::info('found new "' . $key . '" migrations.');
         }
         foreach ($value as $time => $path) {
             $migration = new static($path);
             // run the migration
             $migration->up();
             if (\ClanCats::is_cli()) {
                 \CCCli::success('migrated ' . $migration->name());
             }
         }
         static::$config->set($key . '.revision', $time);
     }
     if (!$silent) {
         static::$config->write();
     }
 }
Example #10
0
 public static function setCacheNameSpace($name)
 {
     static::$name = $name;
 }
Example #11
0
 public static function end()
 {
     static::$sections[static::$name] = ob_get_clean();
     static::$name = null;
 }
Example #12
0
 /**
  *  Settings Connection Data
  * 
  * @param  array $args
  * @return void
  */
 public static function setting($args)
 {
     static::$host = $args['host'];
     static::$user = $args['user'];
     static::$pass = $args['pass'];
     static::$name = $args['name'];
 }
Example #13
0
 /**
  * Sets database connection settings as properties.
  */
 public static function init($dbName, $dbHost, $dbUser, $dbPass, $tablePrefix = '', $dbDriver = 'mysql')
 {
     static::$name = $dbName;
     static::$host = $dbHost;
     static::$user = $dbUser;
     static::$pass = $dbPass;
     static::$prefix = $tablePrefix;
     // Skip driver check if reinitializing with same driver.
     if (isset(static::$driver) && $dbDriver == static::$driver) {
         return;
     }
     $drivers = PDO::getAvailableDrivers();
     if (!in_array($dbDriver, $drivers, true)) {
         throw new OutOfBoundsException("Invalid database driver {$dbDriver}.");
     }
     static::setDriver($dbDriver);
 }
Example #14
0
 /**
  * Get the route name of this Restful controller.
  *
  * @return string
  */
 public static function name()
 {
     if (!isset(static::$name)) {
         $explodedClass = explode('\\', static::className());
         static::$name = array_pop($explodedClass);
     }
     return static::$name;
 }
Example #15
0
 public static function init($name = 'alien-session')
 {
     static::$name = $name;
     $handler_class = Config::get('session.handlers')[Config::get('session.handler')];
     static::$handler = new $handler_class();
 }
 /**
  * This method should be called before any attempt to log a message.
  *
  * <b>Example</b>
  * @code
  *   No2_Logger::setup([
  *     'name'  => 'My App.',
  *     'level' => No2_Logger::WARN,
  *     'logfile_path' => '/var/log/webapp.log'
  *   ]);
  * @endcode
  *
  * @param $params
  *   A associative array with the following keys:
  *   - name (optional, default: '')
  *       the name of the application
  *   - level (optional, default: INFO)
  *       the logging level. Messages sent to No2_Logger above this value
  *       will silently be ignored. It can be an integer (using this class
  *       constants) or a string (that will be passed to string_to_level()).
  *   - syslog_facility (optional, default: LOG_LOCAL0)
  *       set to a syslog facility if syslog logging is desired. Use for
  *       example LOG_LOCAL0.
  *   - logfile_path (optional)
  *       Path to a writable log file (will be opened in append mode).
  *
  * @return
  *   false on error, true otherwise.
  */
 public static function setup($params)
 {
     $level = array_key_exists('level', $params) ? $params['level'] : self::INFO;
     if (is_string($level)) {
         $level = static::string_to_level($level);
     }
     if (!is_numeric($level) || $level < self::EMERG || $level > self::_NO2_DEBUG) {
         return false;
     }
     $name = array_key_exists('name', $params) ? $params['name'] : '';
     $syslog = false;
     if (array_key_exists('syslog_facility', $params)) {
         $facility = $params['facility'];
         if (!openlog($name, LOG_ODELAY, $facility)) {
             return false;
         }
         static::$syslog = true;
     }
     $fd = null;
     if (array_key_exists('logfile_path', $params)) {
         $fd = fopen($params['logfile_path'], 'a');
         if (!$fd) {
             return false;
         }
         static::$fd = $fd;
     }
     /*
      * this ensure that either the logger is fully setup, or no config
      * values has changed since the last call.
      */
     static::$level = $level;
     static::$name = $name;
     static::$fd = $fd;
     static::$syslog = $syslog;
     static::$reqid = uuidv4();
     return true;
 }
Example #17
0
 /**
  * Set the name of the session to use.
  *
  * @param string $name The name of the session
  *
  * @return void
  */
 public static function name($name)
 {
     static::$init = null;
     static::$name = $name;
     static::$data = [];
 }
Example #18
0
 /**
  * @param int $length
  * @return int
  */
 public function fork($length = 1)
 {
     // run parent process
     $this->start();
     // new sub process
     for ($i = 0; $i < $length; $i++) {
         $process = new static($this->callback, $this->stdout, $this->pipe);
         if (!empty($this->name)) {
             $process->name($this->name);
         }
         if (true === $this->daemonize) {
             $process->daemon();
         }
         $pid = $process->start();
         if (false === $pid) {
             return -1;
         }
         $this->processes[$pid] = $process;
     }
     return 0;
 }
Example #19
0
 /**
  * Set the name of the session to use.
  *
  * @param string $name The name of the session
  *
  * @return void
  */
 public static function name($name)
 {
     static::$name = $name;
     static::$session = null;
 }