Esempio n. 1
0
 public function run(Reflector $refl, $context)
 {
     if ($refl instanceof ReflectionProperty) {
         $annotation = Helper::getAnnotation($refl, Config::class);
         $path = explode('.', $annotation->value);
         $config = $this->config;
         while (!empty($path)) {
             $config = $config->{array_shift($path)};
         }
         $type = Helper::getPropertyType($refl);
         $isPrimitiveType = in_array($type, Constants::$php_default_types) || in_array($type, Constants::$php_pseudo_types);
         $refl->setAccessible(true);
         if ($type !== null && $isPrimitiveType) {
             if (gettype($config) === $type) {
                 $refl->setValue($context, $config);
             } elseif ($type === 'array' && method_exists($config, 'toArray')) {
                 $refl->setValue($context, $config->toArray());
             }
         } else {
             $refl->setValue($context, $config);
         }
     }
 }
Esempio n. 2
0
 public function getAnnotation($name, $values = null)
 {
     return Helper::getAnnotation($this, $name, $values);
 }
Esempio n. 3
0
 /**
  * @param ReflectionProperty $refl
  * @return string
  */
 public static function getServiceName(ReflectionProperty $refl)
 {
     $annotation = AnnotationHelper::getAnnotation($refl, Qualifier::class);
     if ($annotation) {
         return $annotation->value;
     }
     return null;
 }