Пример #1
0
 /**
  * Get doc comment
  * @param ReflectionAnnotatedClass|ReflectionAnnotatedMethod|ReflectionAnnotatedProperty $reflection
  * @return mixed[]
  */
 private function parse($reflection)
 {
     $key = sprintf('%s@%s', $this->addendum->getInstanceId(), ReflectionName::createName($reflection));
     if (!isset(self::$cache[$key])) {
         //
         if (!CoarseChecker::mightHaveAnnotations($reflection)) {
             self::$cache[$key] = [];
             return self::$cache[$key];
         }
         $parser = new AnnotationsMatcher();
         $data = [];
         $parser->setPlugins(new MatcherConfig(['addendum' => $this->addendum, 'reflection' => $reflection]));
         $parser->matches($this->getDocComment($reflection), $data);
         self::$cache[$key] = $data;
     }
     return self::$cache[$key];
 }
Пример #2
0
 /**
  *
  * @param string $metaClass
  * @param AnnotatedInterface|object|string $component
  * @param MetaOptions|Addendum $options
  */
 public function __construct($metaClass = null, $component = null, $options = null)
 {
     if (null === self::$runtimePath) {
         self::$runtimePath = (new ConfigDetector())->getRuntimePath();
     }
     $this->path = self::$runtimePath . '/addendum';
     $this->metaClass = $metaClass;
     $this->component = $component;
     if (empty($options)) {
         $this->instanceId = Addendum::DefaultInstanceId;
     } elseif ($options instanceof Addendum) {
         $this->instanceId = $options->getInstanceId();
     } elseif ($options instanceof MetaOptions) {
         $this->instanceId = $options->instanceId;
     } else {
         throw new UnexpectedValueException('Unknown options');
     }
     $this->prepare();
     $this->addendum = Addendum::fly($this->instanceId);
     $this->nsCache = new NsCache(dirname($this->getFilename()), $this->addendum);
 }