Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2

Bug #15377 StoreFalse and StoreTrue actions should have a boolean default value
Submitted: 2008-12-22 10:07 UTC
From: izi Assigned: izi
Status: Closed Package: Console_CommandLine (version CVS)
PHP Version: 5.2.7 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2008-12-22 10:07 UTC] izi (David Jean Louis)
Description: ------------ When theses options are not passed in the command line, the value is set to NULL, the value should be false for StoreTrue actions, and true for StoreFalse actions. Test script: --------------- <?php require_once 'Console/CommandLine.php'; $parser = new Console_CommandLine(); $parser->addOption('test_storetrue', array( 'short_name' => '-t', 'description' => 'test storetrue action', 'action' => 'StoreTrue', )); $parser->addOption('test_storefalse', array( 'short_name' => '-f', 'description' => 'test storefalse action', 'action' => 'StoreFalse', )); var_dump($parser->parse()); ?> Expected result: ---------------- object(Console_CommandLine_Result)#8 (4) { ["options"]=> array(3) { ["test_storetrue"]=> bool(false) ["test_storefalse"]=> bool(true) ["help"]=> NULL } ["args"]=> array(0) { } ["command_name"]=> bool(false) ["command"]=> bool(false) } Actual result: -------------- object(Console_CommandLine_Result)#8 (4) { ["options"]=> array(3) { ["test_storetrue"]=> NULL ["test_storefalse"]=> NULL ["help"]=> NULL } ["args"]=> array(0) { } ["command_name"]=> bool(false) ["command"]=> bool(false) }

Comments

 [2008-12-22 15:12 UTC] izi (David Jean Louis)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. This cannot be done without breaking backward compatibility, so I added an option to force this behavior (default is false): $parser->force_options_defaults = true;