#27150 [Opn]: 2 feature requests, directly accessing returned arrays, and statics by reference

From: Date: Wed, 04 Feb 2004 18:45:40 +0000
Subject: #27150 [Opn]: 2 feature requests, directly accessing returned arrays, and statics by reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-54401@lists.php.net to get a copy of this message
ID: 27150 User updated by: sven at leon dot uia dot mx -Summary: array returning mechanism from objects? Reported By: sven at leon dot uia dot mx Status: Open Bug Type: Feature/Change Request Operating System: All (redhat 90) PHP Version: 5.0.0b3 (beta3) New Comment: oops: forgot to write correct summarym, done Previous Comments: ------------------------------------------------------------------------ [2004-02-04 13:43:39] sven at leon dot uia dot mx 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 this bug report at http://bugs.php.net/?id=27150&edit=1

« previous php.bugs (#54401) next »