blob: fc41fa6ee65c35efa9b5e3245675dd644a675b65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
--TEST--
Nullable return value
--FILE--
<?php
function foo($x) : ?array {
return $x;
}
foo([]);
echo "ok\n";
foo(null);
echo "ok\n";
foo(0);
?>
--EXPECTF--
ok
ok
Fatal error: Uncaught TypeError: Return value of foo() must be of the type array or null, int returned in %s030.php:3
Stack trace:
#0 %s030.php(10): foo(0)
#1 {main}
thrown in %s030.php on line 3
|