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

Bug #2677 Empty array for $arguments parameter
Submitted: 2004-11-03 10:51 UTC
From: toggg Assigned: scottmattocks
Status: Closed Package: Console_Getargs
PHP Version: Irrelevant OS: FC2
Roadmaps: (Not assigned)    
Subscription  


 [2004-11-03 10:51 UTC] toggg
Description: ------------ It's not really a bug but more something uneasy needing some "work around" to come clear. That can sound strange but a script using Getargs can want to pass an empty array as $arguments to factory(). Meaning is simply the script wants to get only the "defaults if not set" from getargs config without to have to compute this config. In fact, when passing an empty array, Getargs proceeds the $_SERVER['argv'] (what can be something else, e.g. over HTTP, it's the GET string) Work around is first empty this $_SERVER['argv'], but that should be avoided. As said, $arguments in factory() and init() parameter list should better be defaulted to null as array(). Then init() can distinguish between $argument is empty array and no $argument was passed. (see code diff) Reproduce code: --------------- 212c212 < function &factory($config = array(), $arguments = array()) --- > function &factory($config = array(), $arguments = null) 534c534 < function init($config, $arguments = array()) --- > function init($config, $arguments = null) 536c536 < if (is_array($arguments) && count($arguments)) { --- > if (is_array($arguments)) {

Comments

 [2004-11-17 21:55 UTC] scottmattocks
The patch has been applied. The feature will be available in version 1.2.1 Thank you, Scott Mattocks