summaryrefslogtreecommitdiff
path: root/Zend/tests/object_types/return_type_inheritance_in_class.phpt
blob: 69e5af6580926e2a6c05a5af422be4c8c8208a19 (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
--TEST--
Adding class method a object return type during inheritance is allowed
--FILE--
<?php

class One {
    public function a() {}
}

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

$three = new class extends 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