Example #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]);
     }
 }