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 #6219

Reference behaviour error

Details

Submitted2005-12-11 13:44 UTC
Fromhn at ondskap dot net
Assignedwenz
StatusClosed
PackageConsole_Getargs
PHP Version5.0.5
OSLinux 2.6.12
Roadmaps(Not assigned)

Comments

[2005-12-11 13:44 UTC] hn at ondskap dot net

Description:
------------
At line 418 of Getargs.php:

$long = reset(explode('|', $long));

You try to reset() a result ov explode(). The
explode()-result is not bound to any variable, so this
fails.

mixed reset ( array &array )

as reset() is working on the reference.

See the patch below.

Test script:
---------------
--- /usr/share/php/Console/Getargs.php 2005-12-11
14:17:33.000000000 +0100
+++ /usr/share/php/Console/Getargs2.php 2005-12-11
14:37:23.000000000 +0100
@@ -415,7 +415,8 @@
foreach ($config as $long => $def) {

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

// Treat the "parameters" specially.
if ($long == CONSOLE_GETARGS_PARAMS) {
@@ -1059,4 +1060,4 @@
* c-basic-offset: 4
* End:
*/
-?>
\ No newline at end of file
+?>

Expected result:
----------------
Fatal error: Only variables can be passed by reference
in /usr/share/php/Console/Getargs.php on line 418