<?php
class A1
{
protected function a()
{
$i = 0;
$s = '';
while (true) {
$i++;
if ($i > 10000) {
break;
}
foreach ([['a' => 1], 2, ['a' => 2]] as $p) {
if ($p == 2) {
continue;
}
if ($i % 1000 == 999) {
throw new \Exception('t');
}
yield $p['a'] => 123;
}
}
}
public function b()
{
$sum = 0;
try {
foreach ($this->a() as $k => $v) {
$sum += $k + $v;
}
echo 'Done: ', $sum;
} catch (\Exception $e) {
echo $e;
}
}
}
(new A1)->b();
- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Exception: t in /in/hSHVf:20
Stack trace:
#0 /in/hSHVf(33): A1->a()
#1 /in/hSHVf(43): A1->b()
#2 {main}
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
- exception 'Exception' with message 't' in /in/hSHVf:20
Stack trace:
#0 /in/hSHVf(33): A1::a()
#1 /in/hSHVf(43): A1->b()
#2 {main}
preferences:
127.58 ms | 402 KiB | 198 Q