1--TEST-- 2SplObjectStorage unset and destructor edge cases 3--FILE-- 4<?php 5class HasDestructor { 6 public function __destruct() { 7 echo "In destructor. Should no longer be accessible in \$s:\n"; 8 var_dump($GLOBALS['s']); 9 10 throw new RuntimeException("thrown from destructor"); 11 } 12} 13$o = new stdClass(); 14$s = new SplObjectStorage(); 15$s[$o] = new HasDestructor(); 16try { 17 unset($s[$o]); 18} catch (Exception $e) { 19 echo "Caught: {$e->getMessage()}\n"; 20} 21var_dump($s); 22$s[$o] = new HasDestructor(); 23try { 24 $s->offsetUnset($o); 25} catch (Exception $e) { 26 echo "Caught: {$e->getMessage()}\n"; 27} 28 29var_dump($s); 30?> 31--EXPECT-- 32In destructor. Should no longer be accessible in $s: 33object(SplObjectStorage)#2 (1) { 34 ["storage":"SplObjectStorage":private]=> 35 array(0) { 36 } 37} 38Caught: thrown from destructor 39object(SplObjectStorage)#2 (1) { 40 ["storage":"SplObjectStorage":private]=> 41 array(0) { 42 } 43} 44In destructor. Should no longer be accessible in $s: 45object(SplObjectStorage)#2 (1) { 46 ["storage":"SplObjectStorage":private]=> 47 array(0) { 48 } 49} 50Caught: thrown from destructor 51object(SplObjectStorage)#2 (1) { 52 ["storage":"SplObjectStorage":private]=> 53 array(0) { 54 } 55}