Example #1
0
 public function __construct($class, $name)
 {
     if (self::$adapterClass !== null) {
         $this->adapter = new self::$adapterClass($class, $name);
     } else {
         parent::__construct($class, $name);
     }
 }
Example #2
0
 /**
  * @param Reflector $refl
  * @param object $context
  */
 public function run(Reflector $refl, $context)
 {
     if ($refl instanceof \ReflectionProperty) {
         $type = Helper::getPropertyType($refl);
         $isPrimitiveType = in_array($type, Constants::$php_default_types) || in_array($type, Constants::$php_pseudo_types);
         if (!($refl instanceof ReflectionProperty || method_exists($refl, 'getAnnotation'))) {
             $refl = new ReflectionProperty($refl->getDeclaringClass()->getName(), $refl->getName());
         }
         $serviceName = ($qualifier = $refl->getAnnotation(Qualifier::class)) ? $qualifier->value : null;
         if (($type === null || $isPrimitiveType) && $serviceName === null) {
             throw new RuntimeException("Must set the property type by @var annotation or you must use @Quealifier annotation to define the service");
         }
         if (empty($serviceName)) {
             $serviceName = $type;
         }
         $service = BeanFactory::getInstance()->getBean($serviceName);
         $refl->setAccessible(true);
         $refl->setValue($context, $service);
     }
 }
 private function setFormFieldValue(ReflectionProperty $property, $form, $value)
 {
     //var_dump(func_get_args());
     if ($value !== null) {
         if (!$property->isPublic()) {
             $property->setAccessible(true);
         }
         $property->setValue($form, $value);
     }
 }
 /**
  * @covers PhSpring\Reflection\ReflectionProperty::getDeclaringClass
  */
 public function testGetDeclaringClass()
 {
     $class = $this->object->getDeclaringClass();
     $this->assertInstanceOf(ReflectionClass::class, $class);
 }