ID:               35291
 Updated by:       [EMAIL PROTECTED]
 Reported By:      viewport2heaven at yahoo dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Variables related
 Operating System: Red Hat 4.0.1-5
 PHP Version:      4.4.1
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip




Previous Comments:
------------------------------------------------------------------------

[2005-11-19 06:26:48] viewport2heaven at yahoo dot com

Description:
------------
When returning a newly created object, PHP throws up a notice (sounds
like warning) like "Only variable references should be returned by
reference".

This happens in PEAR::Mail_Mime, location Mail/mime.php on line 320. I
don't think this is a Mail_Mime error.

The one on line 593 is a Mail_Mime error, though. It returns the value
of a function call, and that function called wasn't declared with
return-by-reference.

Even if this isn't a bug by your standards (and by the PHP manual
written by you guys), please do consider it a feature request? I
upgraded from 4.4.0 just because I thought you guys fixed this issue.

I'm using Mail 1.1.9 and Mail_Mime 1.3.1.

My PHP config:

--enable-safe-mode
--disable-short-tags
--with-apxs=myapxs
--enable-discard-path
--enable-fastcgi
--with-mysql



Reproduce code:
---------------
function &_addTextPart(&$obj, $text)
{
  $params['content_type'] = 'text/plain';
  $params['encoding']     = $this->_build_params['text_encoding'];
  $params['charset']      = $this->_build_params['text_charset'];
  if (is_object($obj)) {
    return $obj->addSubpart($text, $params);
  } else {
    return new Mail_mimePart($text, $params); // Offending line!!
  }
}

function &headers($xtra_headers = null)
{
  // Content-Type header should already be present,
  // So just add mime version header
  $headers['MIME-Version'] = '1.0';
  if (isset($xtra_headers)) {
    $headers = array_merge($headers, $xtra_headers);
  }
  $this->_headers = array_merge($headers, $this->_headers);

  return $this->_encodeHeaders($this->_headers); // Offending line!!
}

Expected result:
----------------
There shouldn't be a notice when we return a new instantiation of an
object through a function declared to return by-reference.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35291&edit=1

Reply via email to