[php-src] Issue #9735: Problem in WeakReference
| From: | xjaja | Date: | Wed, 12 Oct 2022 12:32:45 +0000 |
| Subject: | [php-src] Issue #9735: Problem in WeakReference | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242584@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9735
Author: xjaja
### Description
behavior1: [3v4l](https://3v4l.org/JCiiQ#v8.1.11)
behavior2: [3v4l](https://3v4l.org/JJWSX#v8.1.11)
The following code:
```php
<?php
class ClassName1
{
function __destruct() {
print "Destroying " . __CLASS__ . "\n";
}
}
$fiber = new Fiber(
function() {
$d1 = new ClassName1;
// Resulted output
$d2 = \WeakReference::create(\Fiber::getCurrent())->get();
// Expected output
//\WeakReference::create(\Fiber::getCurrent())->get();
Fiber::suspend();
return ;
}
);
echo "1\n";
$fiber->start();
echo "2\n";
$fiber = null;
echo "3\n";
```
Resulted in this output:
```
1
2
3
Destroying ClassName1
```
But I expected this output instead:
```
1
2
Destroying ClassName1
3
```
### PHP Version
php 8.1.11
### Operating System
_No response_