summaryrefslogtreecommitdiff
path: root/Zend/tests/return_types/030.phpt
blob: 0550f6f40b10e70c6de022f507ad3b0d669a4087 (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, integer returned in %s030.php:3
Stack trace:
#0 %s030.php(10): foo(0)
#1 {main}
  thrown in %s030.php on line 3