PHP 5.5 Generator during iteration

Code
<?php

define
('REWIND''doing rewind' PHP_EOL);
define('NEXT''doing next' PHP_EOL);
define('CURRENT''show current: ');
define('VALID''is valid: ');

$func = function() {
    echo 
'+ start' PHP_EOL;
    
$array range(02);
    
    foreach(
$array as $int) {
        echo 
'+ before yield' PHP_EOL;
        yield 
$int;
        echo 
'+ after yield' PHP_EOL;
    }
    echo 
'+ end' PHP_EOL;
};

$generator $func();

// processing like in a loop
echo REWIND;
$generator->rewind();
echo 
VALID;
echo 
'"' $generator->valid() . '"' PHP_EOL;
echo 
CURRENT;
echo 
'"' $generator->current() . '"' PHP_EOL;
echo 
NEXT;
$generator->next();
echo 
VALID;
echo 
'"' $generator->valid() . '"' PHP_EOL;
echo 
CURRENT;
echo 
'"' $generator->current() . '"' PHP_EOL;
echo 
NEXT;
$generator->next();
echo 
VALID;
echo 
'"' $generator->valid() . '"' PHP_EOL;
echo 
CURRENT;
echo 
'"' $generator->current() . '"' PHP_EOL;
echo 
NEXT;
$generator->next();
echo 
VALID;
echo 
'"' $generator->valid() . '"' PHP_EOL;
Result
doing rewind
+ start
+ before yield
is valid: "1"
show current: "0"
doing next
+ after yield
+ before yield
is valid: "1"
show current: "1"
doing next
+ after yield
+ before yield
is valid: "1"
show current: "2"
doing next
+ after yield
+ end
is valid: ""
Used Versions
PHP 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8