Ejemplo n.º 1
0
 /**
  * process
  *
  * @param string $str
  * @return string
  */
 public static function process($str)
 {
     $result = "";
     $codeParser = new Miaox_Aop_CodeParser($str);
     while (($token = $codeParser->nextToken()) !== null) {
         // Internal characters ( ie, (, {, }, ) ) do not have a token_name
         if (is_array($token)) {
             $result .= Miaox_Aop_CodeCruncher::analizeToken($token, $codeParser->getIndex(), $codeParser->getInit());
         } else {
             if (is_string($token)) {
                 $result .= $token;
             }
         }
     }
     return trim($result);
 }
Ejemplo n.º 2
0
 /**
  * Разбор блока
  *
  * @param array $token
  * @return string
  */
 protected function _compileAutoClassOrMethodToken($token)
 {
     // Append token into result string
     $result = $token[1];
     $tk = $this->_codeParser->nextToken();
     // Finding the next parsable token
     while (!is_array($tk) || is_array($tk) && token_name((int) $tk[0]) != "T_STRING") {
         // T_WHITESPACE or &
         $tk = $this->_codeParser->nextToken();
     }
     // T_STRING
     $nextToken = $this->_codeParser->currentToken();
     // Include the class/function name into stack
     array_push($this->_defStack, array($token[1], $nextToken[1]));
     $tk = $this->_codeParser->currentToken();
     // Returning to the last parsable token
     while (!is_array($tk) || is_array($tk) && (token_name((int) $tk[0]) != "T_CLASS" && token_name((int) $tk[0]) != "T_FUNCTION")) {
         // Anything else: T_CLASS / T_FUNCTION
         $tk = $this->_codeParser->previousToken();
     }
     return $result;
 }