summaryrefslogtreecommitdiff
path: root/Zend/tests/return_types/030.phpt
blob: 2f4cb696d5d5207e804f54458d3d7bc5d952e9e4 (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: foo(): Return value must be of type ?array, int returned in %s:%d
Stack trace:
#0 %s030.php(10): foo(0)
#1 {main}
  thrown in %s030.php on line 3