<?php class WeakAnalysingMapRepro { /** @var workaround https://github.com/php/php-src/issues/13612, remove once PHP 8.3 support is dropped */ private \stdClass $destructedEarly; public array $destroyed = []; public array $ownerDestructorHandlers = []; public function __construct() { $this->destructedEarly = new \stdClass(); $handler = new class($this, $this->destructedEarly) { private \WeakReference $weakAnalysingMap; private \WeakReference $weakAnalysingMapDestructedEarly; public function __construct(WeakAnalysingMapRepro $analysingMap, \stdClass $destructedEarly) { $this->weakAnalysingMap = \WeakReference::create($analysingMap); $this->weakAnalysingMapDestructedEarly = \WeakReference::create($destructedEarly); } public function __destruct() { if ($this->weakAnalysingMapDestructedEarly->get() === null) { return; } var_dump($this->weakAnalysingMap->get()); } }; $this->destroyed[] = 1; $this->ownerDestructorHandlers[] = $handler; } } new WeakAnalysingMapRepro(); echo 'DONE';
You have javascript disabled. You will not be able to edit any code.