PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Console » Console_Getargs » Bug #5697

Fatal error: Only variables can be passed by reference

Details

Submitted2005-10-15 07:52 UTC
Fromryan at wonko dot com
Assignedwenz
StatusClosed
PackageConsole_Getargs
PHP Version5.0.5
OSFreeBSD 5.4
Roadmaps(Not assigned)

Comments

[2005-10-15 07:52 UTC] ryan at wonko dot com

Description:
------------
Any attempt to use Getargs in PHP 5.0.5 fails with the error message "Fatal error: Only variables can be passed by reference".

This error message is generated by lines 418 and 426 in Getargs.php.

[2005-12-04 11:39 UTC] jacob at aub dot dk

The following patch seems to work, beware that it hasn't been extensively tested and probably breaks some pear code conventions:

--- /usr/local/lib/php/pear/Console/Getargs.php Sun Dec 4 10:50:51 2005
+++ Getargs.php Sun Dec 4 12:28:23 2005
@@ -415,18 +415,18 @@
foreach ($config as $long => $def) {

// We only really care about the first option name.
- $long = reset(explode('|', $long));
+ $long = explode('|', $long);

// Treat the "parameters" specially.
if ($long == CONSOLE_GETARGS_PARAMS) {
continue;
}
// We only really care about the first option name.
- $def['short'] = reset(explode('|', $def['short']));
+ $def['short'] = explode('|', $def['short']);

if (!isset($def['min']) || $def['min'] == 0 || isset($def['default'])) {
// This argument is optional.
- if (isset($def['short']) && strlen($def['short']) == 1) {
+ if (isset($def['short']) && count($def['short']) == 1) {
$optional = $def['short'] . $optional;
$optionalHasShort = true;
} else {
@@ -434,7 +434,7 @@
}
} else {
// This argument is required.
- if (isset($def['short']) && strlen($def['short']) == 1) {
+ if (isset($def['short']) && count($def['short']) == 1) {
$required = $def['short'] . $required;
$requiredHasShort = true;
} else {
@@ -1059,4 +1059,4 @@
* c-basic-offset: 4
* End:
*/
-?>
\ No newline at end of file
+?>