/** * Разбор блока * * @param array $token * @param integer $i * @param integer $init * @return string */ public static function analizeToken($token, $i, $init) { $result = ""; switch (token_name((int) $token[0])) { case "T_WHITESPACE": case "T_ENCAPSED_AND_WHITESPACE": // New line between commands fixer $result .= " "; break; // [ FIXME ]: Implement a fix for this situation // [ FIXME ]: Implement a fix for this situation case "T_CONSTANT_ENCAPSED_STRING": // New line in string definition fixer $result .= $token[1]; break; case "T_OPEN_TAG": if ($i == $init && is_array($token[1])) { // Last weird behavior of PHP Tokenizer... it puts // the first PHP command as part of the T_OPEN_TAG $result .= Miaox_Aop_CodeCruncher::analizeToken($token[1], $i, $init); } else { $result .= trim($token[1]); } break; case "T_COMMENT": case "T_ML_COMMENT": case "T_DOC_COMMENT": // Do nothing break; default: $result .= $token[1]; break; } return $result; }
/** * Возвращает код advice секции для auto pointcut * * @param string $class * @param string $method * @param string $autoPointcut * @return Miaox_Aop_Advice */ public function &getAdviceFromAutoPointcut($class, $method, $autoPointcut) { $advice = new Miaox_Aop_Advice(); $a =& $this->_weave->getAdviceFromAutoPointcut($class, $method, $autoPointcut); $code = $a->getData(); // Does it has any code to replace? if (strlen($code) > 0) { // PHP Code Cruncher if ($this->_compact) { $code = Miaox_Aop_CodeCruncher::process($code); } else { $code = "\r\n" . $code . "\r\n"; } // Add an informative text $code = "/* AOP \"" . $autoPointcut . "\" Auto Code */ " . $code . " "; } $advice->addData($code); return $advice; }