예제 #1
0
 /**
  * @param $target
  *
  * @return mixed
  */
 private function checkTargetConstraints($target)
 {
     $reflection = new RokCommon_Annotation_ReflectionClass($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("RokCommon_Annotation '" . get_class($this) . "' nesting not allowed", E_USER_ERROR);
         } else {
             trigger_error("RokCommon_Annotation '" . get_class($this) . "' not allowed on " . $this->createName($target), E_USER_ERROR);
         }
     }
 }
예제 #2
0
 /**
  * @param RokCommon_Annotation_ReflectionClass $class
  *
  * @return bool|RokCommon_Annotation_ReflectionProperty
  */
 protected static function &getDefaultKeyProperty(RokCommon_Annotation_ReflectionClass &$class)
 {
     if (!isset(self::$cache[$class->getName()]['_default_key_'])) {
         self::$cache[$class->getName()]['_default_key_'] = false;
         if ($class->hasAnnotation('RokCommon_JSON_Annotation_JSONDefaultKey')) {
             $property = $class->getProperty($class->getAnnotation('RokCommon_JSON_Annotation_JSONDefaultKey')->value);
             self::$cache[$class->getName()]['_default_key_'] = $property;
         }
     }
     return self::$cache[$class->getName()]['_default_key_'];
 }