« first day (5174 days earlier)   

12:10
@Sjon what is happening with 3v4l? It seems to be down for me.
 
1 hour later…
13:34
Static variables inside functions are very interesting
I only just realised you don't need to ??= assign to them for them to work that way. Actually, I found it frustrating that you can't declare and assign to them that way on the same line using ??=, until I realised plain assign = works the same way in this context
But what about generator functions? i.e. combining static $foo and yield. Each time the function is executed, it will create a new generator. So does it also allocate new memory for the "static" variable, or is it still shared?
13:59
You could just test it. But the storage should be shared I believe.
14:51
It's not that easy to test
But sure, I could
You could just document it :^)
But the documentation glosses over such a case
Since generator functions are effectively factory methods, I don't think it should just be assumed to work the same as all other methods
 
2 hours later…
17:05
:57802460

function test($value) {
    static $x;
    if ($x === null) {
        $x = $value;
    }
    var_dump($x);
    yield $x;
}

foreach (test(1) as $_);
foreach (test(2) as $_);
17:18
I also did a quick test and it seems to work as expected
```
class C {
public function __construct()
{
echo 'LOL YEA';
}

}

function f() {
static $c = new C;

yield;
}
f()->current();
f()->current();
```

« first day (5174 days earlier)