1--TEST-- 2unserialize with references to typed properties shall skip the references or fail 3--FILE-- 4<?php 5 6class A { 7 public int $a; 8 public $b; 9} 10 11class B { 12 public $a; 13 public int $b; 14} 15 16class C { 17 public int $a; 18 public string $b; 19} 20 21class D { 22 public int $a; 23 public float $b; 24} 25 26var_dump(unserialize('O:1:"A":2:{s:1:"a";i:1;s:1:"b";R:2;}')); 27var_dump(unserialize('O:1:"B":2:{s:1:"a";i:1;s:1:"b";R:2;}')); 28 29try { 30 var_dump(unserialize('O:1:"A":2:{s:1:"a";N;s:1:"b";R:2;}')); 31} catch (TypeError $e) { 32 echo $e->getMessage(), "\n"; 33} 34try { 35 var_dump(unserialize('O:1:"B":2:{s:1:"a";N;s:1:"b";R:2;}')); 36} catch (TypeError $e) { 37 echo $e->getMessage(), "\n"; 38} 39try { 40 var_dump(unserialize('O:1:"C":2:{s:1:"a";i:1;s:1:"b";R:2;}')); 41} catch (TypeError $e) { 42 echo $e->getMessage(), "\n"; 43} 44try { 45 var_dump(unserialize('O:1:"C":2:{s:1:"b";s:1:"x";s:1:"a";R:2;}')); 46} catch (TypeError $e) { 47 echo $e->getMessage(), "\n"; 48} 49try { 50 var_dump(unserialize('O:1:"D":2:{s:1:"a";i:1;s:1:"b";R:2;}')); 51} catch (TypeError $e) { 52 echo $e->getMessage(), "\n"; 53} 54 55?> 56--EXPECT-- 57object(A)#1 (2) { 58 ["a"]=> 59 &int(1) 60 ["b"]=> 61 &int(1) 62} 63object(B)#1 (2) { 64 ["a"]=> 65 &int(1) 66 ["b"]=> 67 &int(1) 68} 69Typed property A::$a must be int, null used 70Typed property B::$b must be int, null used 71Typed property C::$b must be string, int used 72Typed property C::$a must be int, string used 73Reference with value of type int held by property D::$a of type int is not compatible with property D::$b of type float 74