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