Bug #69419 [Asn]: Returning compatible sub generator produces a warning

From: Date: Fri, 10 Apr 2015 15:33:38 +0000
Subject: Bug #69419 [Asn]: Returning compatible sub generator produces a warning
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191942@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69419&edit=1 ID: 69419 Updated by: nikic@php.net Reported by: elliotlevin at hotmail dot com Summary: Returning compatible sub generator produces a warning Status: Assigned Type: Bug Package: Scripting Engine problem PHP Version: master-Git-2015-04-10 (Git) Assigned To: nikic Block user comment: N Private report: N New Comment: The behavior in PHP 7 is correct, I'll fix it to throw a strict standards notice in 5.x as well. Previous Comments: ------------------------------------------------------------------------ [2015-04-10 13:02:37] elliotlevin at hotmail dot com Description: ------------ When generators were implemented, a generator function could return another generator even if it was a return by reference generator. In PHP7 this now produces a warning because it is not a variable. See http://3v4l.org/sFR11#vphp7@20141101 Test script: --------------- <?php function & genRefInner() { $var = 1; yield $var; } function & genRefOuter() { return genRefInner(); } foreach(genRefOuter() as $i) { var_dump($i); } ?> Expected result: ---------------- int(1) Actual result: -------------- Notice: Only variable references should be returned by reference in /in/sFR11 on line 9 int(1) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69419&edit=1

« previous php.bugs (#191942) next »