@@ -8,6 +8,7 @@ interface Y {}
8
8
9
9
class A implements X, Y {}
10
10
class B {}
11
+ class C {}
11
12
12
13
class Test {
13
14
public X &Y |int $ prop1 ;
@@ -50,13 +51,77 @@ $test->prop2 = $i;
50
51
$ test ->bar1 ($ a );
51
52
$ test ->bar2 ($ a );
52
53
$ test ->bar1 ($ b );
53
- $ test ->bar2 ($ b ); // This currently fails
54
+ $ test ->bar2 ($ b );
54
55
$ test ->prop3 = $ a ;
55
56
$ test ->prop4 = $ b ;
56
57
$ test ->prop3 = $ a ;
57
58
$ test ->prop4 = $ b ;
58
59
60
+ $ c = new C ();
61
+ try {
62
+ $ test ->foo1 ($ c );
63
+ } catch (\TypeError $ e ) {
64
+ echo $ e ->getMessage (), \PHP_EOL ;
65
+ }
66
+ try {
67
+ $ test ->foo2 ($ c );
68
+ } catch (\TypeError $ e ) {
69
+ echo $ e ->getMessage (), \PHP_EOL ;
70
+ }
71
+ try {
72
+ $ test ->bar1 ($ c );
73
+ } catch (\TypeError $ e ) {
74
+ echo $ e ->getMessage (), \PHP_EOL ;
75
+ }
76
+ try {
77
+ $ test ->bar2 ($ c );
78
+ } catch (\TypeError $ e ) {
79
+ echo $ e ->getMessage (), \PHP_EOL ;
80
+ }
81
+ try {
82
+ $ test ->prop1 = $ c ;
83
+ } catch (\TypeError $ e ) {
84
+ echo $ e ->getMessage (), \PHP_EOL ;
85
+ }
86
+ try {
87
+ $ test ->prop2 = $ c ;
88
+ } catch (\TypeError $ e ) {
89
+ echo $ e ->getMessage (), \PHP_EOL ;
90
+ }
91
+ try {
92
+ $ test ->prop3 = $ c ;
93
+ } catch (\TypeError $ e ) {
94
+ echo $ e ->getMessage (), \PHP_EOL ;
95
+ }
96
+ try {
97
+ $ test ->prop4 = $ c ;
98
+ } catch (\TypeError $ e ) {
99
+ echo $ e ->getMessage (), \PHP_EOL ;
100
+ }
101
+
59
102
?>
60
103
===DONE===
61
- --EXPECT--
104
+ --EXPECTF--
105
+ object(A)#2 (0) {
106
+ }
107
+ object(A)#2 (0) {
108
+ }
109
+ int(10)
110
+ int(10)
111
+ object(A)#2 (0) {
112
+ }
113
+ object(A)#2 (0) {
114
+ }
115
+ object(B)#3 (0) {
116
+ }
117
+ object(B)#3 (0) {
118
+ }
119
+ Test::foo1(): Argument #1 ($v) must be of type X&Y|int, C given, called in %s on line %d
120
+ Test::foo2(): Argument #1 ($v) must be of type X&Y|int, C given, called in %s on line %d
121
+ Test::bar1(): Argument #1 ($v) must be of type B|X&Y, C given, called in %s on line %d
122
+ Test::bar2(): Argument #1 ($v) must be of type X&Y|B, C given, called in %s on line %d
123
+ Cannot assign C to property Test::$prop1 of type X&Y|int
124
+ Cannot assign C to property Test::$prop2 of type X&Y|int
125
+ Cannot assign C to property Test::$prop3 of type X&Y|B
126
+ Cannot assign C to property Test::$prop4 of type B|X&Y
62
127
===DONE===
0 commit comments