mirror of
https://github.com/php/php-src.git
synced 2026-04-21 06:51:18 +02:00
From now on, we always display the given object's type instead of just reporting "object". Additionally, make the format of return type errors match the format of argument errors. Closes GH-5625
41 lines
676 B
PHP
41 lines
676 B
PHP
--TEST--
|
|
Incorrect elision of return type checks
|
|
--SKIPIF--
|
|
<?php require_once('skipif.inc'); ?>
|
|
--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 $e->getMessage() . "\n";
|
|
}
|
|
|
|
class Foo {}
|
|
function test2() : Foo {
|
|
$obj = new stdClass;
|
|
return $obj;
|
|
}
|
|
|
|
try {
|
|
test2();
|
|
} catch (Error $e) {
|
|
echo $e->getMessage() . "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
test1(): Return value must be of type callable, string returned
|
|
test2(): Return value must be of type Foo, stdClass returned
|