Exemplo n.º 1
0
 public function __construct($data = [], $target = false)
 {
     $reflection = new ReflectionClass($this);
     $class = $reflection->name;
     if (isset(self::$_creationStack[$class])) {
         throw new CircularReferenceException("Circular annotation reference on '{$class}'", E_USER_ERROR);
     }
     self::$_creationStack[$class] = true;
     foreach ($data as $key => $value) {
         if ($reflection->hasProperty($key)) {
             $this->{$key} = $value;
         }
         $this->_properties[$key] = $value;
     }
     foreach ($reflection->getProperties(ReflectionProperty::IS_PUBLIC) as $field) {
         $this->_publicProperties[] = $field->name;
     }
     try {
         ConflictChecker::register($this, $target);
         TargetChecker::check($this, $target);
     } catch (UnexpectedValueException $ex) {
         throw $ex;
     } finally {
         unset(self::$_creationStack[$class]);
     }
 }