php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35291 erroneous notice concerning return by reference
Submitted: 2005-11-19 06:26 UTC Modified: 2005-11-27 01:00 UTC
From: viewport2heaven at yahoo dot com Assigned:
Status: No Feedback Package: Variables related
PHP Version: 4.4.1 OS: Red Hat 4.0.1-5
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-11-19 06:26 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC