|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-01-19 11:42 UTC] cmb@php.net
-Status: Open
+Status: Verified
-Type: Bug
+Type: Documentation Problem
[2019-01-19 11:42 UTC] cmb@php.net
[2019-01-21 10:50 UTC] cmb@php.net
[2019-01-21 10:51 UTC] cmb@php.net
-Status: Verified
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2019-01-21 10:51 UTC] cmb@php.net
[2020-02-07 06:05 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 19 14:00:02 2025 UTC |
Description: ------------ When a function has a YIELD instruction inside a IF instruction, the yield instruction is called even if the IF INSTRUCTION is not true. Tested whith 7.0.33, 7.1.26 and 7.2.14 versions. Test script: --------------- function gen_one_to_three($useYield = true) { $result = []; for ($i = 1; $i <= 3; $i++) { if (true === $useYield) { yield $i; } else { $result[] = $i; } } if (false === $useYield) { return $result; } } $return1 = gen_one_to_three(true); echo get_class($return1) $return2 = gen_one_to_three(false); echo get_class($return2); Expected result: ---------------- Generator PHP Warning: get_class() expects parameter 1 to be object, array given Actual result: -------------- Generator Generator