Example #1
0
 public function getStructure(IFunctionReflection $reflection)
 {
     $globalHash = $reflection->getGlobalHash();
     if (!isset(self::$resolvedFunctionCache[$globalHash])) {
         $functionStructure = $this->parser->parse($reflection);
         $functionMagic = $reflection->resolveMagic($functionStructure->getDeclaration());
         self::$resolvedFunctionCache[$globalHash] = $functionStructure->resolveMagic($functionMagic);
     }
     return self::$resolvedFunctionCache[$globalHash];
 }
Example #2
0
 public final function parse(IFunctionReflection $reflection)
 {
     $innerReflection = $reflection->getInnerReflection();
     if (!$innerReflection->isUserDefined()) {
         throw new InvalidFunctionException('Cannot parse function %s: function is not user defined', $innerReflection->getName());
     }
     $filePath = $reflection->getLocation()->getFilePath();
     if (!is_readable($filePath)) {
         throw new InvalidFunctionException('Cannot parse function %s: \'%s\' is not a valid accessible file', $innerReflection->getName(), $filePath);
     }
     try {
         return $this->parseFunction($reflection, $filePath);
     } catch (ASTException $astException) {
         throw InvalidFunctionException::invalidFunctionMessage($astException->getMessage(), $innerReflection);
     }
 }