File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Zend/tests/type_declarations Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ Overriding static return types with self in final class
3+ --FILE--
4+ <?php
5+
6+ interface A
7+ {
8+ public function method1 (): static ;
9+ }
10+
11+ abstract class B
12+ {
13+ abstract public function method2 (): static ;
14+ }
15+
16+ trait C
17+ {
18+ abstract public function method3 (): static ;
19+ }
20+
21+ final class Foo extends B implements A
22+ {
23+ use C;
24+
25+ public function method1 (): self
26+ {
27+ return $ this ;
28+ }
29+
30+ public function method2 (): self
31+ {
32+ return $ this ;
33+ }
34+
35+ public function method3 (): self
36+ {
37+ return $ this ;
38+ }
39+ }
40+
41+ $ foo = new Foo ();
42+
43+ var_dump ($ foo ->method1 ());
44+ var_dump ($ foo ->method2 ());
45+ var_dump ($ foo ->method3 ());
46+ ?>
47+ --EXPECT--
48+ object(Foo)#1 (0) {
49+ }
50+ object(Foo)#1 (0) {
51+ }
52+ object(Foo)#1 (0) {
53+ }
You can’t perform that action at this time.
0 commit comments