public function testRawMatcher() { $model = new ModelWithConstantValue(); $reflection = new ReflectionAnnotatedClass($model); $matcher = new AnnotationsMatcher(); $matcher->setPlugins(new MatcherConfig(['addendum' => new Addendum(), 'reflection' => new ReflectionClass($this)])); $matches = []; $matcher->matches(Addendum::getDocComment($reflection), $matches); }
public function testIfWillExtractTopValues() { $model = new ModelWithTopValues(); // Raw matcher for debug $reflection = new ReflectionAnnotatedProperty($model, 'straight'); $matcher = new AnnotationsMatcher(); $matcher->setPlugins(new MatcherConfig(['addendum' => new Addendum(), 'reflection' => $reflection])); $data = []; $comment = Addendum::getDocComment($reflection); $matcher->matches($comment, $data); $meta = Meta::create($model); // All fields have same annotation foreach ($meta->fields() as $fieldMeta) { $title = sprintf('Annotation is defined on %s', $fieldMeta->name); $this->assertSame(ModelWithTopValues::ClassValue, $fieldMeta->class); $this->assertSame(ModelWithTopValues::UpdatableValue, $fieldMeta->updatable); } }
/** * Get doc comment * @param ReflectionAnnotatedClass|ReflectionAnnotatedMethod|ReflectionAnnotatedProperty $reflection * @return mixed[] */ protected function getDocComment($reflection) { return Addendum::getDocComment($reflection); }