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 E {
17    public $a;
18    public int $b;
19}
20
21class C {
22    public int $a;
23    public string $b;
24}
25
26class D {
27    public int $a;
28    public float $b;
29}
30
31var_dump(unserialize('O:1:"A":2:{s:1:"a";i:1;s:1:"b";R:2;}'));
32var_dump(unserialize('O:1:"B":2:{s:1:"a";i:1;s:1:"b";R:2;}'));
33var_dump(unserialize('O:1:"E":2:{s:1:"a";i:1;s:1:"b";R:2;}'));
34
35try {
36    var_dump(unserialize('O:1:"A":2:{s:1:"a";N;s:1:"b";R:2;}'));
37} catch (TypeError $e) {
38    echo $e->getMessage(), "\n";
39}
40try {
41    var_dump(unserialize('O:1:"B":2:{s:1:"a";N;s:1:"b";R:2;}'));
42} catch (TypeError $e) {
43    echo $e->getMessage(), "\n";
44}
45try {
46    var_dump(unserialize('O:1:"C":2:{s:1:"a";i:1;s:1:"b";R:2;}'));
47} catch (TypeError $e) {
48    echo $e->getMessage(), "\n";
49}
50try {
51    var_dump(unserialize('O:1:"C":2:{s:1:"b";s:1:"x";s:1:"a";R:2;}'));
52} catch (TypeError $e) {
53    echo $e->getMessage(), "\n";
54}
55try {
56    var_dump(unserialize('O:1:"D":2:{s:1:"a";i:1;s:1:"b";R:2;}'));
57} catch (TypeError $e) {
58    echo $e->getMessage(), "\n";
59}
60
61?>
62--EXPECT--
63object(A)#1 (2) {
64  ["a"]=>
65  &int(1)
66  ["b"]=>
67  &int(1)
68}
69object(B)#1 (2) {
70  ["a"]=>
71  &int(1)
72  ["b"]=>
73  &int(1)
74}
75object(E)#1 (2) {
76  ["a"]=>
77  &int(1)
78  ["b"]=>
79  &int(1)
80}
81Cannot assign null to property A::$a of type int
82Cannot assign null to property B::$b of type int
83Cannot assign int to property C::$b of type string
84Cannot assign string to property C::$a of type int
85Reference with value of type int held by property D::$a of type int is not compatible with property D::$b of type float
86