Matthias Pigulla schrieb: >>>So, in case of "return new", wouldn't it make sense to remove the >>>warning as the code is 'legal'? And please, don't start a new "it's >>>just a friendly notice" flame war. >> >> It's just a notice, tune your error_reporting level accordingly. > > > Sorry, but that is just a stupid killer argument. I thought I had > written something like "please, don't start a new *it's just a friendly > notice* flame war".
Jep, that would be a valid argument if one could not just adjust error_reporting level but also the "error_throwing" behaviour. Some people want to get notices, they just don't want to get THIS notice. So if [throw_levels] only_variables_can_be_returned_by_reference = create_temp_and_shut_up_like_other_languages could be configured this would be a valid argument ;-) Other languages can pass objects by reference, not only variables. And in the (conceptionally) most advanced languages like Ruby even returning a 3 means returning an object. A function defined as returning by reference should always quietly create anonymous containers if the code returns non-variable-stored values. This most prominently happens with return new Classname(); And I personally also believe that function &huba() { return 3; } should implicitly be interpreted by PHP as $internal_variable_with_random_or_no_name=3 return &$internal_variable_with_random_or_no_name; The name doesn't matter as the caller doesn't want to know it. > May I conclude that what you really want to say is: > > "Yes, return /*byref*/ new Foo() _is_ bad code _unless_ inside Foo's > constructor, $this is passed around and somebody somewhere stores yet This somebody should be PHP. > another reference to it. Accept that you wrote broken code: return new > Foo() is wrong, it needs to be return $tmp =& new Foo()." > > Shaking his head, > Matthias I second that. Let's go to the disco ;-) OLLi ____________ Backup? Backup? ...I knew I forgot something! -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php