We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1134d8e commit a5a7a35Copy full SHA for a5a7a35
Zend/tests/type_declarations/static_type_trait.phpt
@@ -0,0 +1,38 @@
1
+--TEST--
2
+static type in trait
3
+--FILE--
4
+<?php
5
+
6
+trait T {
7
+ public function test($arg): static {
8
+ return $arg;
9
+ }
10
+}
11
12
+class C {
13
+ use T;
14
15
+class P extends C {
16
17
18
+$c = new C;
19
+$p = new P;
20
+var_dump($c->test($c));
21
+var_dump($c->test($p));
22
+var_dump($p->test($p));
23
+var_dump($p->test($c));
24
25
+?>
26
+--EXPECTF--
27
+object(C)#1 (0) {
28
29
+object(P)#2 (0) {
30
31
32
33
34
+Fatal error: Uncaught TypeError: Return value of C::test() must be an instance of P, instance of C returned in %s:%d
35
+Stack trace:
36
+#0 %s(%d): C->test(Object(C))
37
+#1 {main}
38
+ thrown in %s on line %d
0 commit comments