private function checkTargetConstraints($target)
 {
     $reflection = new ReflectionAnnotatedClass($this);
     if ($reflection->hasAnnotation('Target')) {
         $value = $reflection->getAnnotation('Target')->value;
         $values = is_array($value) ? $value : array($value);
         foreach ($values as $value) {
             if ($value == 'class' && $target instanceof ReflectionClass) {
                 return;
             }
             if ($value == 'method' && $target instanceof ReflectionMethod) {
                 return;
             }
             if ($value == 'property' && $target instanceof ReflectionProperty) {
                 return;
             }
             if ($value == 'nested' && $target === false) {
                 return;
             }
         }
         if ($target === false) {
             trigger_error("Annotation '" . get_class($this) . "' nesting not allowed", E_USER_ERROR);
         } else {
             trigger_error("Annotation '" . get_class($this) . "' not allowed on " . $this->createName($target), E_USER_ERROR);
         }
     }
 }
 /**
  * Scans for declared components between declared classes.
  */
 private function scanComponents()
 {
     $enabledPrefixes = array_merge(self::$APPLICATIONS, array_keys($this->modules));
     foreach (get_declared_classes() as $class) {
         if (Strings::startsWithOneOf($class, $enabledPrefixes)) {
             $classReflection = new ReflectionAnnotatedClass($class);
             if (Reflection::inheritFrom($class, self::COMPONENT_PARENT_CLASS)) {
                 if (!$classReflection->hasAnnotation(self::COMPONENT_ANNOTATION)) {
                     $this->log->console("DEFINITION ERROR: {$class} extends Component, but has no annotation 'Component'");
                     continue;
                 }
                 $componentAnnotation = $classReflection->getAnnotation(self::COMPONENT_ANNOTATION);
                 $componentName = $componentAnnotation->value;
                 $this->log->console("Component:  \t {$componentName} -> {$class}");
                 if (array_key_exists($componentName, $this->components)) {
                     throw new DeploymentException("Multiple component definition: " . $this->components[$componentName]['class'] . " -> " . $class);
                 }
                 $this->components[$componentName] = [];
                 $this->components[$componentName]['class'] = $class;
                 $this->components[$componentName]['annotations'] = [];
                 foreach ($classReflection->getAllAnnotations() as $annot) {
                     $this->components[$componentName]['annotations'][] = $this->exportAnnotation($annot);
                 }
                 $this->components[$componentName]['properties'] = [];
                 $this->components[$componentName]['methods'] = [];
                 foreach ($classReflection->getProperties() as $reflectProp) {
                     $reflectAnnotations = $reflectProp->getAllAnnotations();
                     if (!empty($reflectAnnotations)) {
                         $this->components[$componentName]['properties'][$reflectProp->name] = [];
                         $this->components[$componentName]['properties'][$reflectProp->name]['annotations'] = [];
                         foreach ($reflectAnnotations as $propAnnot) {
                             $this->components[$componentName]['properties'][$reflectProp->name]['annotations'][] = $this->exportAnnotation($propAnnot);
                         }
                     }
                 }
                 foreach ($classReflection->getMethods() as $reflectMethod) {
                     $this->processMethod($componentName, $reflectMethod);
                 }
             }
         }
     }
 }