Beispiel #1
0
 /**
  * Point the current storage to the prefixing point.
  * This session manager will later point every session operation (has, get, set, getAll, destroy) on this key level
  * Another prefix will not to a new prefix, except append to the current reference.
  * @return \Exedra\Session\Session
  */
 public function setPrefix($prefix)
 {
     $storage =& \Exedra\Support\DotArray::getReference($this->getStorage(), $prefix);
     $this->set($prefix, $storage);
     $this->storage =& $storage;
     return $this;
 }
Beispiel #2
0
 /**
  * Get config through array offset
  * @param string $key
  * @return mixed
  */
 public function &offsetGet($key)
 {
     if (!$this->has($key)) {
         return null;
     }
     return \Exedra\Support\DotArray::getReference($this->storage, $key);
 }
Beispiel #3
0
 /**
  * Parse docblock to key-value array
  * @param string text
  * @return array
  */
 protected function parseDocBlock($text)
 {
     // http://www.murraypicton.com/archive/building-a-phpdoc-parser-in-php
     if (preg_match('#^/\\*\\*(.*)\\*/#s', $text, $comment) === false) {
         return array();
     }
     if (!isset($comment[1])) {
         return array();
     }
     $comment = trim($comment[1]);
     // http://www.murraypicton.com/archive/building-a-phpdoc-parser-in-php
     if (preg_match_all('#^\\s*\\*(.*)#m', $comment, $lines) === false) {
         return array();
     }
     $data = array();
     $lastParam = null;
     foreach ($lines[1] as $line) {
         $line = trim($line);
         if ($line[0] !== '@') {
             if ($lastParam) {
                 $lastParam .= '\\n' . $line;
             }
             continue;
         }
         @(list($key, $value) = explode(' ', $line, 2));
         $key = substr($key, 1);
         \Exedra\Support\DotArray::set($data, $key, trim($value));
         $lastParam =& \Exedra\Support\DotArray::getReference($data, $key);
     }
     foreach ($data as $key => $value) {
         if (!isset($this->commandParamAliases[$key])) {
             continue;
         }
         unset($data[$key]);
         $data[$this->commandParamAliases[$key]] = $value;
     }
     return $data;
 }