1
0
mirror of https://github.com/php/php-src.git synced 2026-04-16 20:41:18 +02:00
Files
archived-php-src/ext/opcache/tests/ssa_bug_003.phpt
Nikita Popov e6296f0dcc Fix VERIFY_RETURN_TYPE elision
This both fixes incorrect elision and allows elision for cases
where we only have a subset (e.g. true of bool).
2016-06-05 23:44:08 +02:00

39 lines
669 B
PHP

--TEST--
Incorrect elision of return type checks
--FILE--
<?php
function test1($x) : callable {
if ($x == 1) {
$c = 'foo';
} elseif ($x == 2) {
$c = new stdClass;
} else {
$c = [$x => &$x];
}
return $c;
}
try {
test1(1);
} catch (Error $e) {
echo "Error: {$e->getMessage()}\n";
}
class Foo {}
function test2() : Foo {
$obj = new stdClass;
return $obj;
}
try {
test2();
} catch (Error $e) {
echo "Error: {$e->getMessage()}\n";
}
?>
--EXPECT--
Error: Return value of test1() must be callable, string returned
Error: Return value of test2() must be an instance of Foo, instance of stdClass returned