AW: [PHP-DEV] return /* by reference */ new Foo() in PHP4
| From: | Matthias Pigulla | Date: | Sun, 09 Oct 2005 10:14:38 +0000 |
| Subject: | AW: [PHP-DEV] return /* by reference */ new Foo() in PHP4 | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-19529@lists.php.net to get a copy of this message | ||
> > 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".
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
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