Loop won't keep, if not reference in object EvWatcher

Issue #22 invalid
Alex Sky created an issue

Its work (reference $w)

$i = 0;

$w = new EvTimer(0, 1.0, function() use(&$i)
{
    $i++;
    echo "$i\r\n";
});

Ev::run();

Its not work (not reference $w)

$i = 0;

new EvTimer(0, 1.0, function() use(&$i)
{
    $i++;
    echo "$i\r\n";
});

Ev::run();

Comments (3)

  1. Ruslan Osmanov repo owner

    As designed. You don't expect any returned PHP variable to exist, if you ignore it, do you? So that's the same thing.

  2. Log in to comment