xref: /php-src/ext/opcache/tests/ssa_bug_003.phpt (revision e9f783fc)
1--TEST--
2Incorrect elision of return type checks
3--EXTENSIONS--
4opcache
5--FILE--
6<?php
7
8function test1($x) : callable {
9    if ($x == 1) {
10        $c = 'foo';
11    } elseif ($x == 2) {
12        $c = new stdClass;
13    } else {
14        $c = [$x => &$x];
15    }
16    return $c;
17}
18
19try {
20    test1(1);
21} catch (Error $e) {
22    echo $e->getMessage() . "\n";
23}
24
25class Foo {}
26function test2() : Foo {
27    $obj = new stdClass;
28    return $obj;
29}
30
31try {
32    test2();
33} catch (Error $e) {
34    echo $e->getMessage() . "\n";
35}
36
37?>
38--EXPECT--
39test1(): Return value must be of type callable, string returned
40test2(): Return value must be of type Foo, stdClass returned
41