<?php
namespace JLSalinas\RWGen;

trait GeneratorAggregateHack
{
    public function send($value)
    {
        static $generator = null;
        
        if ($generator === null) {
            if ($value === null) {
                return;
            }
            $generator = $this->getGenerator();
        }
        $generator->send($value);
        if ($value === null) {
            $generator = null;
        }
    }
    
    public function __destruct()
    {
        $this->send(null);
    }
}

<?php
namespace JLSalinas\RWGen;

trait GeneratorAggregateHack
{
    protected $generator = null;
    public function send($value)
    {
        if ($this->generator === null) {
            if ($value === null) {
                return;
            }
            $this->generator = $this->getGenerator();
        }
        $this->generator->send($value);
        if ($value === null) {
            $this->generator = null;
        }
    }
    
    public function __destruct()
    {
        $this->send(null);
    }
}

Fix static generator causing only one output at a time
Fix static generator causing only one output at a time
