Пример #1
0
 protected function populateField(\ReflectionProperty $prop, InputInterface $input)
 {
     $comment = new DocComment($prop->getDocComment());
     $defaults = $prop->getDeclaringClass()->getDefaultProperties();
     if ($comment->hasTag('argument')) {
         $arg = $input->getArgument((int) $comment->getTagValue('argument'), NULL);
         if ($arg === NULL) {
             $arg = $defaults[$prop->name];
         }
         $this->{$prop->name} = $arg;
     } elseif ($comment->hasTag('option')) {
         $shorty = (string) $comment->getTagValue('option');
         if ($shorty !== '' && $input->hasOption($shorty)) {
             $this->{$prop->name} = $input->getOption($shorty);
             return;
         }
         $this->{$prop->name} = $input->getOption($prop->name, $defaults[$prop->name]);
     }
 }
Пример #2
0
 public function isPassthroughAttribute($attr)
 {
     $key = get_class($this);
     if (!array_key_exists($key, self::$ownAttributes)) {
         $ref = new \ReflectionClass($key);
         self::$ownAttributes[$key] = [];
         foreach ($ref->getProperties(\ReflectionProperty::IS_PUBLIC) as $prop) {
             if ($prop->isStatic()) {
                 continue;
             }
             self::$ownAttributes[$key][$prop->name] = $prop;
         }
     }
     if (empty(self::$ownAttributes[$key][$attr])) {
         return true;
     }
     $ref = self::$ownAttributes[$key][$attr];
     if ($ref->isPublic() && $ref->isDefault() && !$ref->isStatic()) {
         $comment = new DocComment($ref->getDocComment());
         if ($comment->hasTag('passthrough')) {
             return true;
         }
     }
     return false;
 }