/** {@inheritdoc} */
 public function runPrinter()
 {
     $targets = [Annotation::TARGET_CLASS => "Class", Annotation::TARGET_METHOD => "Method", Annotation::TARGET_PROPERTY => "Property"];
     foreach ($targets as $targetIdentifier => $targetName) {
         $this->printAnnotationsByTarget($targetName, $this->annotationReaderResult->getAnnotationsByTarget($targetIdentifier));
     }
     return $this;
 }
 /**
  * Validates a reader result against the provided definition.
  * @param \Brickoo\Component\Common\Collection $collection
  * @param \Brickoo\Component\Annotation\AnnotationReaderResult $readerResult
  * @throws \Brickoo\Component\Annotation\Exception\MissingRequiredAnnotationException
  * @throws \Brickoo\Component\Annotation\Exception\MissingRequiredAnnotationParametersException
  * @return void
  */
 public function validate(Collection $collection, AnnotationReaderResult $readerResult)
 {
     $targets = [Annotation::TARGET_CLASS, Annotation::TARGET_METHOD, Annotation::TARGET_PROPERTY];
     $annotationFilter = new AnnotationDefinitionTargetFilter($collection);
     foreach ($targets as $annotationTarget) {
         $this->validateAnnotations($annotationFilter->filter($annotationTarget), $readerResult->getAnnotationsByTarget($annotationTarget));
     }
 }
<?php

use Brickoo\Component\Annotation\Annotation;
use Brickoo\Component\Annotation\AnnotationReaderResult;
/**
 * Annotations:
 * @Dependency ("value")
 * @Dependency ("@dependencyId")
 */
$readerResult = new AnnotationReaderResult("dependency.definition", "\\SomeClass");
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_CLASS, "\\SomeClass", "Dependency", ["value"]));
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_METHOD, "\\SomeClass::someMethod", "Dependency", ["@dependencyId"]));
return $readerResult;
<?php

use Brickoo\Component\Annotation\Annotation;
use Brickoo\Component\Annotation\AnnotationReaderResult;
/**
 * Annotations:
 * @Controller (path = "/")
 * @Route (path = "/list")
 * @Assert (maxlength = 30)
 */
$readerResult = new AnnotationReaderResult("definition.name", "\\SomeClass");
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_CLASS, "\\SomeClass", "Controller", ["path" => "/"]));
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_METHOD, "\\SomeClass::displayBookList", "Route", ["path" => "/list"]));
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_PROPERTY, "\\SomeClass::name", "Assert", ["maxlength" => 30]));
return $readerResult;
<?php

use Brickoo\Component\Annotation\Annotation;
use Brickoo\Component\Annotation\AnnotationReaderResult;
/**
 * Annotations:
 * @Controller (path = "/")
 * @Route (path = "/list")
 * @Assert (maxlength = 30)
 */
$readerResult = new AnnotationReaderResult("definition.name", "\\SomeClass");
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_CLASS, "\\SomeClass", "Controller", ["path" => "/"]));
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_METHOD, "\\SomeClass::someAction", "Route", ["path" => "/list"]));
// Missing @Assert Annotation
return $readerResult;
<?php

use Brickoo\Component\Annotation\Annotation;
use Brickoo\Component\Annotation\AnnotationReaderResult;
/**
 * Annotations:
 * @Controller (path = "/")
 * @Route (path = "/list")
 * @Assert (maxlength = 30)
 */
$readerResult = new AnnotationReaderResult("definition.name", "\\SomeClass");
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_CLASS, "\\SomeClass", "Controller", ["path" => "/"]));
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_METHOD, "\\SomeClass", "Route", ["path" => "/list"]));
$readerResult->addAnnotation(new Annotation(Annotation::TARGET_PROPERTY, "\\SomeClass", "Assert", []));
// maxlength missing
return $readerResult;
 /**
  * Adds the annotations to the result collection.
  * @param \Brickoo\Component\Annotation\AnnotationReaderResult $result
  * @param Annotation[] $annotations
  * @return \Brickoo\Component\Annotation\AnnotationReflectionClassReader
  */
 private function addResultAnnotations(AnnotationReaderResult $result, array $annotations)
 {
     foreach ($annotations as $annotation) {
         $result->addAnnotation($annotation);
     }
     return $this;
 }
 /**
  * @covers Brickoo\Component\Annotation\AnnotationReaderResult::getIterator
  * @covers Brickoo\Component\Annotation\AnnotationReaderResult::isTargetValid
  */
 public function testGetIterator()
 {
     $annotationReaderResult = new AnnotationReaderResult("\\Some\\Class");
     $annotationsCollectionIterator = $annotationReaderResult->getIterator();
     $this->assertInstanceOf("\\ArrayIterator", $annotationsCollectionIterator);
     $this->assertEquals(0, count($annotationsCollectionIterator));
     $annotation = $this->getAnnotationStub();
     $annotation->expects($this->any())->method("getTarget")->will($this->returnValue(Annotation::TARGET_CLASS));
     $annotationReaderResult->addAnnotation($annotation);
     $annotationsCollectionIterator = $annotationReaderResult->getIterator();
     $this->assertEquals(1, count($annotationsCollectionIterator));
 }