public function testCanIterate() { $annotation = new MockAnnotation(); $collection = new AnnotationCollection(); $collection->addAnnotation($annotation); foreach ($collection as $key => $a) { $this->assertSame('mock', $key); $this->assertSame([$annotation], $a); } }
/** * Add unique class annotations to collection * * @param ReflectionClass $reflectionClass * @param AnnotationCollection $annotationCollection */ private function getAdditionalClassAnnotations(ReflectionClass $reflectionClass, AnnotationCollection $annotationCollection) { $annotations = $this->reader->getClassAnnotations($reflectionClass); $annotations = $this->getDynamoAnnotations($annotations); foreach ($annotations as $annotation) { // skip annotations that already exist on method if ($annotationCollection->exists($annotation->getName())) { continue; } $annotationCollection->addAnnotation($annotation); } }
public function testGetResponseType() { $method = new MethodModel(new ClassModel('Foo', 'FooClass', 'FooInterface'), 'fooMethod'); $collection = new AnnotationCollection(); $collection->addAnnotation(new ResponseType(['value' => 'array'])); $provider = new AnnotationProvider($collection, $method); $returnType = $provider->getResponseType(); $this->assertSame('array', $returnType); }