From:             sven at leon dot uia dot mx
Operating system: All (redhat 90)
PHP version:      5.0.0b3 (beta3)
PHP Bug Type:     Feature/Change Request
Bug description:  array returning mechanism from objects?

Description:
------------
I have a number of feature requests:

1) Could it be possible to immediately access an array that was returned
from a function, just like its possible to access object functions
immediately? This way its easy to safely access arrays that are privately
stored inside an object (so that another person can not (accidentally)
change information inside that array.

i.e. $temp=$object->return_object($parameter)->data($key);
for an array (that is privately kept inside an object):
     $temp=$object->return_array($parameter)[$key];

where $object->return_array would be like:

function return_array(){
    return $copied_array=$private_array;
}

This same (feature request) has been asked in report 25898, but the given
"possible solution" did not seem to match my question. 

2) Could it be possible for functions that accept parameters by reference,
and return values by reference, to also accept static value's like strings
or booleans?

This would be very nice in situations where I would have to accept a large
string PLUS a small piece of text like "hey", and it would be very usefull
too in situations where I would  have to return either an array or FALSE.

like this:

$data="hey";
test(TRUE, $data."<br>");
function test($param1, &$param2){
  $data=array($param2, "bye");
  If($param1)
  {
    return $data;
  }
  else
  {
    return FALSE;
  }
}

The above script will fail with beta 3 on both the parameters (since a
static string was part of $param2) and the return value (Becouse FALSE is
also not a variable)

This is a functionality I have used alot in other programming languages,
without problems. Sending strings by reference will (in my opinion) make
it possible to optimize your scripts a little more.


-- 
Edit bug report at http://bugs.php.net/?id=27150&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27150&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27150&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27150&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27150&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27150&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27150&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27150&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27150&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27150&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27150&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27150&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27150&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27150&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27150&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27150&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27150&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27150&r=float

Reply via email to