#35728 [Opn->Bgs]: constructors with a return by reference cause a notice to be thrown
| From: | tony2001@php.net | Date: | Sun, 18 Dec 2005 23:32:45 +0000 |
| Subject: | #35728 [Opn->Bgs]: constructors with a return by reference cause a notice to be thrown | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-90624@lists.php.net to get a copy of this message | ||
ID: 35728
Updated by: tony2001@php.net
Reported By: t dot isler at bbn dot de
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
PHP Version: 5.1.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
That's exactly what you get with this:
<?php
function &foo() {}
$test = & foo();
?>
And this is expected behaviour (because your code is obviously wrong).
Also, if you set error_reporting to E_ALL | E_STRICT, you'll see even
more error messages telling you about your code.
Previous Comments:
------------------------------------------------------------------------
[2005-12-19 00:18:50] t dot isler at bbn dot de
Description:
------------
I don't know wether you want to consider the following a bug, but as
far as my understanding of oop is concerned, the behavior of php 4.4
and 5.1 is "unusual" when comes to constructors with a return by
reference.
Reproduce code:
---------------
<?php
class firstObject { function & __construct() {} }
class secondObject { function & __construct() {return $this;} }
$firstObject =& new firstObject();
$secondObject =& new secondObject();
?>
Expected result:
----------------
The first constructor should pass without a problem, the second should
throw an error.
Actual result:
--------------
The first constructor throws a notice, the second passes without any
problem.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35728&edit=1