summaryrefslogtreecommitdiff
path: root/Zend/tests/object_types/return_type_inheritance_in_interface.phpt
blob: fe1f6e6c0c081e33922ae2c01fa523fd30421915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--TEST--
Adding interface method a object return type during inheritance is allowed
--FILE--
<?php

interface One {
    public function a();
}

interface Two extends One {
    public function a() : object;
}

$three = new class implements Two {
    public function a() : object {
        return 12345;
    }
};
$three->a();

--EXPECTF--
Fatal error: Uncaught TypeError: Return value of class@anonymous::a() must be an object, integer returned in %s:13
Stack trace:
#0 %s(16): class@anonymous->a()
#1 {main}
  thrown in %s on line 13