Example #1
0
 public static function parseDocComment($content)
 {
     if (is_object($content) && is_callable(array($content, 'getDocComment'))) {
         $content = $content->getDocComment();
     }
     $id = sha1($content);
     if (isset(self::$internal_cache[$id])) {
         $isCached = true;
         return unserialize(self::$internal_cache[$id]);
     }
     $pzToken = new Tokenizer($content);
     $Parser = new \Notoj_Parser();
     $buffer = array();
     $isNew = true;
     while (true) {
         try {
             $token = $pzToken->getToken($isNew);
             if (!$token) {
                 break;
             }
             $isNew = false;
             $Parser->doParse($token[0], $token[1]);
         } catch (\Exception $e) {
             $buffer = array_merge($buffer, $Parser->body);
             $Parser = new \Notoj_Parser();
             $isNew = true;
         }
     }
     try {
         $Parser->doParse(0, 0);
     } catch (\Exception $e) {
         // ignore error
     }
     $struct = new Annotations(array_merge($buffer, $Parser->body));
     self::$internal_cache[$id] = $struct->toCache();
     return $struct;
 }
Example #2
0
 public static function parseDocComment($content, &$isCached = NULL, $localCache = NULL)
 {
     if (is_object($content) && is_callable(array($content, 'getDocComment'))) {
         $content = $content->getDocComment();
     }
     $id = sha1($content);
     if (isset(self::$internal_cache[$id])) {
         $isCached = true;
         return self::$internal_cache[$id];
     }
     $isCached = false;
     $cached = Cache::Get($id, $found, $localCache);
     if ($found) {
         $isCached = true;
         self::$internal_cache[$id] = new Annotations($cached);
         return self::$internal_cache[$id];
     }
     $pzToken = new Tokenizer($content);
     $Parser = new \Notoj_Parser();
     $buffer = array();
     $isNew = true;
     do {
         try {
             $token = $pzToken->getToken($isNew);
             if (!$token) {
                 break;
             }
             $isNew = false;
             $Parser->doParse($token[0], $token[1]);
         } catch (\Exception $e) {
             $buffer = array_merge($buffer, $Parser->body);
             $Parser = new \Notoj_Parser();
             $isNew = true;
         }
     } while (true);
     try {
         $Parser->doParse(0, 0);
     } catch (\Exception $e) {
         // ignore error
     }
     $struct = new Annotations(array_merge($buffer, $Parser->body));
     Cache::Set($id, $struct, $localCache);
     self::$internal_cache[$id] = $struct;
     return self::$internal_cache[$id];
 }
Example #3
0
 /**
  * Output debug information to output (php://output stream)
  */
 static function PrintTrace()
 {
     self::$yyTraceFILE = fopen('php://output', 'w');
     self::$yyTracePrompt = '';
 }