Skip to content

yield without value in reference generator function does not create notice #16761

Open
@ohyeaah

Description

@ohyeaah

Description

The following code:

<?php
error_reporting(E_ALL);
function &y()
{
  yield null; // warning
  yield; // no warning
}
foreach (y() as &$y);

Resulted in this output:

PHP Notice:  Only variable references should be yielded by reference in /home/user10/test.php on line 5

But I expected this output instead:

PHP Notice:  Only variable references should be yielded by reference in /home/user10/test.php on line 5
PHP Notice:  Only variable references should be yielded by reference in /home/user10/test.php on line 6

PHP Version

PHP 8.2.24 (cli) (built: Sep 27 2024 04:16:10) (NTS)

Operating System

Debian GNU/Linux 12 (bookworm)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions