setDescription('Description for optional argument'); $option->setDefaultValue('must this be numeric ?'); // this resuls in a warning $option->setDefaultValue(6); // this works fine $this->addOption($option); } public function handle(GetOpt $getOpt) { echo $getOpt->getOption('aaa'); } } $getOpt = new GetOpt(); $getOpt->addCommand(new CopyCommand()); // process arguments and catch user errors try { try { $getOpt->process(); } catch (Missing $exception) { // catch missing exceptions if help is requested if (!$getOpt->getOption('help')) { throw $exception; } } } catch (ArgumentException $exception) { echo 'error'; exit; } $command = $getOpt->getCommand(); call_user_func($command->getHandler(), $getOpt);